我需要使用ajax更新自定義選項值。 我想更新它像Magento:使用ajax更新購物車項目自定義選項
$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();
任何一個可以幫助我生根粉是怎麼回事錯在這裏。 謝謝
只是一個瘋狂的猜測..而不是'$ item-> save();',嘗試'$ item-> setOptions($ options) - > save();'。 。 – Kalpesh 2012-07-25 15:50:21
$ item-> setOptions($ options) - > save(); Mage :: getSingleton('checkout/cart') - > save(); 爲我工作。 謝謝 – p4pravin 2012-07-26 12:56:07
很高興!您能否將答案標記爲「已接受」,以便它可以幫助其他用戶? – Kalpesh 2012-07-26 13:52:47