I have this code in checkout/cart/item/default.phtml
$allProductOptions = $_item->getProduct()->getTypeInstance(true)>getOrderOptions($_item->getProduct());
$productOptions = $allProductOptions['info_buyRequest'];
And in $productOptions
I have custom option saved from product page: $productOptions['my_option']
. How can I update that option?
Best Answer
In the code above,
$_item
refers to an instance ofMage_Sales_Model_Quote_Item
, so you can alter the buyRequest with the code below:However I'd definitely not advise altering the buyRequest from a phtml file, if you want to add data in to the buyRequest or change existing data, you should do so via an event observer by listening for
checkout_cart_product_add_after
, which supplied you with the quote item, so you can set data on the buyRequest like so: