add new custom option in cart not work while adding configurable product using observer
-
13-12-2019 - |
Question
when I addtocart
simple product and added new custom option using checkout_cart_product_add_after
,it works perfect and cart displays new custom option in cart but my new custom option does not display while adding configurable product,it display configurable attribute lable and its value('color: blue') but my new custom option does not see.
My config.xml
<checkout_cart_product_add_after>
<observers>
<test_checkout_product_observer>
<type>singleton</type>
<class>test/observer</class>
<method>addTestInfo</method>
</test_checkout_product_observer>
</observers>
</checkout_cart_product_add_after>
My Observer.php
public function addTestInfo($observer)
{
$quoteItem = $observer->getEvent()->getQuoteItem();
$additionalOptions = array(array(
'code' => 'test_shop_info',
'label' => 'label1',
'value' => 'value1',
));
$quoteItem->addOption(array(
'code' => 'additional_options',
'value' => serialize($additionalOptions),
));
return $this;
}
What I want: My new custom option should display in cart while adding configurable product.
This above code works only simple product not for configurable product. Thanks in advance
Solution
Finally I found a solution by folllowing link.
It will be used catalog_product_type_prepare_full_options
observer
http://sonimanthan228.blogspot.in/2015/12/add-new-custom-option-using-observer-in.html