Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
431 views
Welcome To Ask or Share your Answers For Others

1 Answer

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 :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...