Question

I have added an observer on "sales_order_place_before" Event and want to customize grand total before processing the payment. but i have tried a lot to change the quote price but it is not working.

Does anyone have any idea??

Was it helpful?

Solution

You need to add new collector after grand total one (Mage_Sales_Model_Quote_Address_Total_Grand). It has to modify sum that was set by grand total collector.

I spoke about such a case at MageConf conference in Ukraine week ago. Video and slides are not available yet, but you can download demo-module that was described at conference. There is an example of total collector that calculates wrapping price.

You can modify my demo total collector so it'll be inserted in collecting process AFTER Grand total collector (see config.xml in module etc directory - remove <before>subtotal</before> node then use <after>grand_total</after> instead) and modify collect() method just to set grand totals to your predefined values:

$address->setGrandTotal($someValue);
$address->setBaseGrandTotal($someBaseValue);

Or you can leave this module as it is, but set negative totals in it. So Grand total collector will subtract them and lower grand total value as you wish. Also in such a case customer will be able to see your negative values (give them in fetch() method) and understand why grand totals were lowered.

Have fun :)

OTHER TIPS

you can't you have to make a new total object or add sums as virtual products

please observe

Mage_Sales_Model_Quote_Address_Total_Abstract Mage_Sales_Model_Order_Invoice_Total_Abstract Mage_Sales_Model_Order_Creditmemo_Total_Abstract

to see what is needed to implement a total object . You also might need to extend the rate objects

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top