Magento Checkout 中的多个来源邮政编码
我正在为客户开发 Magento 店面。他们使用直销商,因此单个邮政编码对我们没有多大帮助。我们确实将其设置为客户端发货时最常见的邮政编码,因此,在许多情况下,这是可以的。
但是,在某些情况下,需要使用不同的来源邮政编码。在极少数情况下,我们将有多个来源邮政编码。当有一个 zip 与主 zip 不同时,我们将其存储在名为“origin zip”的属性中(有创意,嗯?)
我应该在哪里进行修改?我们只使用 UPS 运输方式,我想做的是,在计算运输之前,获取购物车中可能存在的任何原产地邮政编码(我认为我们已经有了这部分),但是,然后,取决于结果,我可能需要迭代运输计算并将这些值加在一起 - 即,如果他们订购一种具有原产地邮政编码的产品,而另一种没有原产地邮政编码的产品,则必须计算第一个,然后第二个,然后将它们加在一起。
如果有人能指出我们需要修改哪些 php 文件或类的正确方向,我将不胜感激。
I'm working on a Magento storefront for a client. They use dropshippers, so a single zip code doesn't do us much help. We do have it set for the most common zip code from which the client ships, so, in many cases, it's ok.
However, in some cases, there is a different origin zip code that needs to be used. In more rare cases, we will have multiple origin zip codes. When there is a zip that differs from the main one, we have stored this in an attribute called 'origin zip' (creative, huh?)
Where should I be looking to make the modifications? We're only using the UPS shipping method, and what I'm looking to do is, before calculating shipping, to grab whatever origin zips may be in the cart (I think we've got this part), but then, depending on the results, I may need to iterate through the shipping calculation and add the values together - i.e. in the case they order one product with an origin zip code, and another product without an origin zip code, it would have to calculate the first, then the second, and then add them together.
If someone could point us in the correct direction of which php files or classes we'll need to modify, I would greatly appreciate it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您需要将自定义属性添加到将在购物车中使用的属性列表。
请遵循 stackoverflow 上的以下答案:
如何在 magento 1.4.1.1 中将自定义上传的图像添加到购物车?
然后您需要创建自定义的运输方式,也许可以从您的方式扩展。它应该遍历从运输请求中收到的物品并检查不同的邮政编码来源,然后分别计算它们的费率。
我希望您创建一个扩展现有运输方式功能的模块不会成为问题。
干杯!
更新
要将您的属性添加到购物车项目中加载的产品,请使用以下配置:
然后在运输方式模型中使用类似这样的内容(以 USPS 为例):
First of all you need to add your custom attributed to list of attributes that will be used in shopping cart.
Follow these answer on stackoverflow:
How to add custom uploaded images to cart in magento 1.4.1.1?
Then you need to create your custom shipping method, maybe extended from yours one. It should walk through items it receives from shipping request and check for different zip origin, then calculate rate for them separately.
I hope for you it will not be a problem to create a module that will extend existing shipping method functionality.
Cheers!
UPDATE
For adding your attribute to product that is loaded in the cart item use such configuration:
Then in shipping method model use something like this (used USPS as example):
usa/shipping_ups
类负责处理这些请求,具体而言,setRequest
方法似乎满足您的需求:如果您可以将 orig_postcode 添加到运输请求中,UPS 将返回基于该来源的报价。
一种方法是重写
Mage_Shipping_Model_Rate_Request
并添加一个名为getOrigPostcode
的方法。由于是一个真正的方法,这将覆盖默认的 Magento getter/setter 行为。让此方法查询请求的内容以找出需要使用哪个 zip。希望有帮助!
谢谢,
乔
The class
usa/shipping_ups
is what handles these requests, and specifically the methodsetRequest
seems to have what you need:If you can add the orig_postcode to the shipping request, UPS will return a quote based on that origin.
One approach to this would be to override
Mage_Shipping_Model_Rate_Request
and add a method calledgetOrigPostcode
. By virtue of being a real method, this would override the default Magento getter/setter behavior. Have this method query the contents of the request to find out which zip needs to be used.Hope that helps!
Thanks,
Joe