问题描述
我在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) 之后添加新的收集器.它必须修改由grand total收集器设置的sum.
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.
您可以修改我的演示总收集器,以便在总收集器之后将其插入到收集过程中(请参阅模块 etc 目录中的 config.xml - 删除 <before>subtotal</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 结帐过程之前设置自定义总计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!