如何在magento结帐过程之前设置自定义总计?
我在“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.
Does anyone have any idea??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在总计一(Mage_Sales_Model_Quote_Address_Total_Grand)之后添加新的收集器。它必须修改由总计收集器设置的总和。
一周前我在乌克兰的 MageConf 会议上谈到了这样一个案例。视频和幻灯片尚不可用,但您可以下载演示模块会议上进行了描述。有一个计算包装价格的总收集器的示例。
您可以修改我的演示总收集器,以便将其插入到总收集器之后的收集过程中(请参阅模块 etc 目录中的 config.xml - 删除
< before>subtotal
节点,然后使用grand_total
代替)并修改 collect() 方法以设置总计到您的预定义值:或者您可以保留此模块不变,但在其中设置负总数。因此,总收藏家将根据您的意愿减去它们并降低总价值。此外,在这种情况下,客户将能够看到您的负值(在 fetch() 方法中给出)并了解总计降低的原因。
玩得开心 :)
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: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 :)
您不能创建一个新的总计对象或将总和添加为虚拟产品,
请遵守
Mage_Sales_Model_Quote_Address_Total_Abstract
Mage_Sales_Model_Order_Invoice_Total_Abstract
Mage_Sales_Model_Order_Creditmemo_Total_Abstract
查看实现总对象需要什么。您可能还需要扩展费率对象
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