4

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

Jonathan Day
  • 18,519
  • 10
  • 84
  • 137
smart
  • 185
  • 2
  • 4
  • 11

2 Answers2

14

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

Andrey Tserkus
  • 3,644
  • 17
  • 24
  • thanks for help, but i want to change the cart price before placing the new order/checkout process. is it working with the same? – smart Dec 06 '10 at 13:18
  • @clockworkgeek Thanks. It has expired, I will renew it today. Where and how did you find requests about it? – Andrey Tserkus Jul 04 '11 at 16:51
  • @Andrey - There were several posts about it below but have since been deleted as they were not answers. – clockworkgeek Jul 04 '11 at 16:59
  • @clockworkgeek Thanks for noticing it, I've updated the link, hope this will help people :) – Andrey Tserkus Jul 09 '11 at 12:41
  • when i download the module and placed the files in desired folder it gives me the error can not call constuctor. – mjdevloper Nov 16 '11 at 07:24
  • @AndreyTserkus do you have any advice to manage tax also: I mean, what if I want my wrapping (to stick at your example) to include tax, how can I add reflect that tax amount in the tax total? – OSdave Nov 25 '11 at 18:29
  • Here you can find slides from Andrey's presentation http://www.slideshare.net/mageconf/checkout – Roman Snitko Aug 16 '12 at 09:54
  • Download link expired, can you renew it again? Thanks. – MBozic Jul 02 '13 at 22:32
0

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

Anton S
  • 12,750
  • 2
  • 35
  • 37