I want to create new custom option for quote item in my observer. How can I do that? Here is my code:
public function execute(\Magento\Framework\Event\Observer $observer) {
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$price = '100'; //set your price here
$item->setCustomPrice($price);
$item->setOriginalCustomPrice($price);
$item->getProduct()->setIsSuperMode(true);
}
I am setting custom price but I also need to set some custom options. I have created observer on checkout_cart_product_add_after event.
Best Answer
You can use
catalog_product_type_prepare_full_options
event if you want to set custom optionIn this event you can easily get
$product
object by usingset your custom option by
Add this custom option by
just it,