问题描述
我在sales_order_place_before事件中添加了一个观察者,并希望在处理付款之前自定义总计。但是我已经尝试了很多来改变报价,但是它不起作用。
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.
有没有人有任何想法?
推荐答案
您需要在总计一个(Mage_Sales_Model_Quote_Address_Total_Grand)之后添加新的收藏者。它必须修改由总收藏家设置的总和。
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.
我在一周前在乌克兰的MageConf会议上谈到了这样的情况。视频和幻灯片尚不可用,但您可以在会议上被描述。有一个计算包装价格的总收藏家的例子。
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.
您可以修改我的演示总收集器,以便在收集整个收藏者后收集(见 config> 在等目录中删除< before>小计< / before>
节点,然后使用< after> grand_total< / after>
代替)并修改 collect()方法,只是为了将总计设置为预定义值:
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);
或者您可以将此模块原样保留,但在其中设置负数总计。所以,总收藏家将减少它们,并根据您的需要降低总体总价值。同样在这种情况下,客户将能够看到您的负值(在 fetch()方法中给出),并了解为什么总计降低。
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.
玩乐:)
这篇关于如何在magento中结帐过程之前设置自定义总计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!