如何在magento结帐过程之前设置自定义总计?

发布于 2024-10-06 20:19:16 字数 98 浏览 6 评论 0原文

我在“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

┼── 2024-10-13 20:19:16

您需要在总计一(Mage_Sales_Model_Quote_Address_Total_Grand)之后添加新的收集器。它必须修改由总计收集器设置的总和。

一周前我在乌克兰的 MageConf 会议上谈到了这样一个案例。视频和幻灯片尚不可用,但您可以下载演示模块会议上进行了描述。有一个计算包装价格的总收集器的示例。

您可以修改我的演示总收集器,以便将其插入到总收集器之后的收集过程中(请参阅模块 etc 目录中的 config.xml - 删除 < before>subtotal 节点,然后使用 grand_total 代替)并修改 collect() 方法以设置总计到您的预定义值:

$address->setGrandTotal($someValue);
$address->setBaseGrandTotal($someBaseValue);

或者您可以保留此模块不变,但在其中设置负总数。因此,总收藏家将根据您的意愿减去它们并降低总价值。此外,在这种情况下,客户将能够看到您的负值(在 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:

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

幽梦紫曦~ 2024-10-13 20:19:16

您不能创建一个新的总计对象或将总和添加为虚拟产品,

请遵守

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文