开发者

how to get id of product in shipping method

开发者 https://www.devze.com 2023-04-11 03:16 出处:网络
Is there anyway to get product Id of product in Shipping module, so that for different category I can charge Additional amount.

Is there anyway to get product Id of product in Shipping module, so that for different category I can charge Additional amount.

for eg: i have to two product in carts. One is in phone category and other开发者_运维技巧 is in computer category. for shipment I have to add $5 for phone and $25 for computer . so shipment charge should be $30 dollars in frontend. Is there anyway I can get product Id and corresponding product's category Id in Shipping method collect rates method??

Please help me, I am in a deep trouble....I hope Eg that I provided , explains what I need.

Thanks in advance.


You can get the products from quote

Mage::getSingleton('checkout/cart')->getQuote()->getAllItems();

or

Mage::getSingleton('checkout/type_onepage')->getQuote()->getAllItems();

and iterating over those items (be aware of grouped and bundled parents and so on) will give you the category(s) they might belong to and you can make your conditions against those


This is only a tenable option if products belong to only one category. Unless something has changed in the last couple of versions, there is no data for quote items that shows the category context from which they were added.

WebShopApps.com has several already-developed solutions for shipping scenarios. Depending on development contract & budget, it may be more cost-effective to use one of their well-tested extensions, e.g. Shipping Override Matrix.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号