I want to add custom option to quoteitem using observer which observer checkoutCartProductAddAfter event and fires after product added to cart.
public function checkoutCartProductAddAfter(Varien_Event_Observer $observer)
{
$item = $observer->getQuoteItem();
$item->addOption(new Varien_Object(
array(
'product' => $item->getProduct(),
'label' => 'Free Gifts',
'value' => 'Spend $50 and get gift product worth $9.99'
)
));
return;
}
My observer is working
but i am not able to add custom option to added product. please provide help to add custom option using observer to just added product.
Best Answer
@Tim gave a talk about this issue on the weekend: https://docs.google.com/presentation/d/1efPznQSVTrT1HAD1xQvCPC-Tgvr8jYok4X7ZEJhm9jE/edit
What you want is Method 2: Add Following Event in Config.xml
In Observer.php add following Method
Here is more about this topic:
https://stackoverflow.com/questions/9334115/magento-change-custom-option-value-before-adding-it-to-cart/9344336#9344336
and more:
https://stackoverflow.com/questions/9412074/magento-quote-order-product-item-attribute-based-on-user-input/9496266#9496266