Search code examples
magentocheckoutobservers

How can update Grand Total on observer in Magento?


I have an observer for the event

controller_action_predispatch_checkout_onepage_savePayment

and I want to change the Grand Total based on some conditions. I tried with:

$value = 100;

$quote = Mage::getSingleton('checkout/type_onepage')->getQuote();

$quote->setGrandTotal($value);

$quote->setTotalsCollectedFlag(false)->collectTotals();

$quote->save();

or

$value = 100;

$quote = Mage::getSingleton('checkout/type_onepage')->getQuote();

$quote->setGrandTotal($value);

$quote->collectTotals();

$quote->save();

But it don't works. Any ideas?

Thanks to all!


Solution

  • The problem was:

    After the event controller_action_predispatch_checkout_onepage_savePayment there's another event who update from zero the grand total, so my changes vanish!