如何根据产品切换运输方式?
我希望能够根据购物车中的商品切换使用的运输方式。 “检查”并找到正确的运输方式的最佳地点在哪里?
它的工作方式是,将使用一个标准的运输方法,然后,如果购物车中有某些商品,另一种方法将覆盖该另一种方法。
我想我可以通过修改各个运输模块来做到这一点,但我想以“正确”的方式做到这一点。
I want to be able to toggle what shipping method is used based upon the items that are in the cart. Where is the best place to "check" this and grab the right shipping method?
The way it will work is that there will be a standard shipping method that is used, and then, if there are certain items in the cart another method will override that other method.
I think I could do this by hacking around in the individual shipping modules, but I'd like to do this the "right" way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
运输方法在 Mage_Shipping_Model_Carrier_Abstract 中内置了方法,它们都扩展了:
扩展您的运输方法并将您的逻辑添加到该方法中,并且不要忘记调用parent::isActive();第一的
shipping methods have built in method in Mage_Shipping_Model_Carrier_Abstract that they all extend:
extend your shipping methods and add your logic to that method and don't forget to call parent::isActive(); first
尝试并尝试,就像我实现自定义覆盖一样,只有当我将整个 Tablerates.php 文件复制到 local/Mage/Shipping/Model/Carrier/Tablerates.php 时,我才能成功。
isActive() 仍然不是“the方式”在这一点上。我必须在collectRates()函数中引入一些代码,如下所示:
它被放置在collectRates函数的开头。
Try and Try as I did to implement a custom override, I was only able to find success when I copied the entire Tablerates.php file to local/Mage/Shipping/Model/Carrier/Tablerates.php
isActive() was still not "the way" at that point. I had to introduce some code in the collectRates() function like so:
This was placed right at the beginning of the collectRates function.