Magento:使用ajax更新购物车项目自定义选项 [英] Magento :Update cart item Custom Option using ajax
本文介绍了Magento:使用ajax更新购物车项目自定义选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用ajax更新自定义选项的值. 我正在尝试像
I need to update the custom option value using ajax. I am trying to update it like
$params = $this->getRequest()->getParams();
$itemID = $params['item'];
$item = Mage::getSingleton('checkout/session')->getQuote()->getItemById($itemID);
$options = $item->getOptions();
foreach ($options as $option) {
if(strtolower($option->getCode()) == 'info_buyRequest')
{
$unserialized = unserialize($option->getValue());
$unserialized['options'][216]= 'New Value';
$option->setValue(serialize($unserialized));
}
}
$item->save();
任何人都可以帮我弄清楚这里出了什么问题吗? 谢谢
Can any one help me abt what is going wrong here. Thanks
推荐答案
Pravin在下面的代码行中使用了它.
Pravin got it worked with below lines of code.
$item->setOptions($options)->save();
Mage::getSingleton('checkout/cart')->save();
感谢p4pravin的分享.
Thanks p4pravin for sharing.
这篇关于Magento:使用ajax更新购物车项目自定义选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文