在 Magento 中使用自定义地址属性结账
我为我的 Customer_Address 创建了一个“地区”属性,因为我的运费是根据它计算的。 此属性在我的结帐中显示得非常好,用户可以毫无问题地从几个选项中进行选择。
然而,当结帐时,我的类中的collectRates()方法会收到一个“Mage_Shipping_Model_Rate_Request”,其中包含有关用户选择结帐的选项的一些信息。 此时,我需要有一种方法来获取用户设置为 District 值的任何内容,以根据该值计算运费,但我似乎无法从 Mage_Shipping_Model_Rate_Request 获取信息。
有没有办法将属性添加到该类以便稍后检索它? 或者 我应该寻求以其他方式获得该价值吗?
您能给我的任何帮助都会非常有用!
谢谢。
I have a ”District” attribute created to my Customer_Address because my shipping is calculated base on it.
This attribute shows perfectly well in my checkout and the user can select from a couple of options with no problem.
However when it checksout, the collectRates() method in my class receives a ”Mage_Shipping_Model_Rate_Request” with some information about the options selected by the user to checkout.
At this point, I need to have a way to get whatever the user has set as the District value to calculate the shipping cost based on that, but I can’t seem to get the information from Mage_Shipping_Model_Rate_Request.
Is there a way I can add the attribute to that class to retrieve it later?
or
Should I be looking to get that value in some other way?
Whatever help you can give me will be very useful!
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你已经解决了这个问题......
无论如何,我遇到了同样的问题并以这种方式解决了它:
重写
Mage_Sales_Model_Quote_Address
和Mage_Shipping_Model_Shipping
,这些是执行的类$request = Mage::getModel('shipping/rate_request');
所以它看起来像
:
I think you solved this already...
Anyway, I had the same problem and solved it this way:
Rewrite
Mage_Sales_Model_Quote_Address
andMage_Shipping_Model_Shipping
, these are the classes that do$request = Mage::getModel('shipping/rate_request');
So it looks like:
and