在购物车中显示Magento自定义选项值 [英] Display Magento Custom Option Values in Shoping Cart

查看:79
本文介绍了在购物车中显示Magento自定义选项值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Magento网站上的一些产品具有自定义选项(不是属性).对于黄金或白银中的一种产品,有两个选项的下拉列表. 如何获得用户选择显示在购物车页面上产品名称旁边的选项的名称?

A few of the products on my Magento site have custom options (not attributes). For one product is available in Gold or Silver an it has a drop down with those two options. How do I get the name of the option the user selected to show next to product name on the shopping cart page?

推荐答案

要在"AddtoCart"时间设置的购物车页面上获取产品自定义选项值,请尝试以下代码.

To get product custom option value at cart page which are set at 'AddtoCart' time try with following code.

$cart = Mage::helper('checkout/cart')->getCart()->getQuote()->getAllItems();

/* cart item loop */
foreach($cart as $item) {

    /* This will get custom option value of cart item */
    $_customOptions = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());

    /* Each custom option loop */
    foreach($_customOptions['options'] as $_option){
        echo $_option['label'] .'=>'. $_option['value']."<br/>";
        // Do your further logic here
    }
}

这篇关于在购物车中显示Magento自定义选项值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆