Magento cart update with ajax.

var postData = jQuery(“#checkout-cart-form”).serializeArray();
jQuery(qtyupdate).closest(‘td’).find(‘.update-cart-qty’).text(‘<?php
echo $this->__(‘Updating’);
?>…’);
jQuery(qtyupdate).closest(‘td’).find(‘.update-cart-qty’).css(‘color’,’#009640′);
jQuery.ajax({
type: “post”,
url: “<?php
echo $this->getUrl(‘checkout/cart/updatePost’);
?>”,
data: postData,
contentType: “application/x-www-form-urlencoded”,
success: function(responseData, textStatus, jqXHR) {
jQuery(‘#header-cart’).replaceWith(jQuery(responseData).find(‘#header-cart’));
jQuery(‘.layout.col1-layout’).replaceWith(jQuery(responseData).find(‘.layout.col1-layout’));
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
}
})

Change custom options value after place order in Magento

<?php
$order = Mage::getModel(‘sales/order’)->load(2547);

foreach ($order->getAllItems() as $item) {
$options = $item->getProductOptions();
$options[‘info_buyRequest’][‘options’][9] = ‘ABCD1’;
$newArray = array(
“label” => ‘Studio Name’,
“value” => ‘ABCD1’,
‘print_value’ => ‘ABCD1’,
‘option_id’ => 9,
‘option_type’ => ‘field’,
‘option_value’ => ‘ABCD1’
);
array_push($options[‘options’], $newArray);
$item->setProductOptions($options);
$item->save();
print_r($item->getProductOptions());
print_r($item->getData());
}