I need to get the selected custom option value of product added in the cart. To observe the product add to cart, i have used an event checkout_cart_product_add_after
In the observer, I have loaded the product using below code:
$item = $observer->getEvent()->getData('quote_item');
$product = $observer->getEvent()->getData('product');
I am able to get product quantity added to the cart using $product->getQty()
however, i am not getting the values of selected custom option.
By using below code i can get all the custom options for product
foreach($product->getOptions() as $o){
$optionType = $o->getType();
foreach($o->getValues() as $value){
echo "<pre>";
print_r($value->getData());
echo "</pre>";
}
}
Can anyone please guide how to get selected option value.
[Edit]
As per the answer by Raphael, i observed an event catalog_product_type_prepare_full_options
and got the value of selected option for the product.
Now, my problem is i need to pass these values to the observer i have created for checkout_cart_product_add_after
. The reason behind this is, I am trying to add a product into cart when certain product with selected custom option is added to the basket.
Is there a way to pass these value to my observer or any better/correct solution for this.