In the code above, $_item
refers to an instance of Mage_Sales_Model_Quote_Item
, so you can alter the buyRequest with the code below:
$buyRequest = $_item->getOptionByCode('info_buyRequest');
$buyRequestArr = unserialize($buyRequest->getValue());
$buyRequestArr['whatever_you_like'] = 'some_value';
$buyRequest->setValue(serialize($buyRequestArr))->save();
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:
public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)
{
$item = $observer->getQuoteItem();
$buyRequestArr = array();
if ($buyRequest = $item->getProduct()->getCustomOption('info_buyRequest')) {
$buyRequestArr = unserialize($buyRequest->getValue());
}
$buyRequestArr['whatever_you_like'] = 'some_value';
$buyRequest->setValue(serialize($buyRequestArr))->save();
}