I have added a custom product attribute with yes/no options. I need to delete products if 'no' attribute option is selected. I have successfully removed cart item using "controller_action_predispatch_checkout_cart_index" event. but i face issue in the following scenerio:
First i set product attribute to yes . This will allow customers to add the product in cart. now go to frontend add product to cart, now go back to admin and set the product attribute option as no. so this will not allow product to cart. but i face trouble for already added product. so i created observer to automatically remove on cart predispatch. but what if customer go directly to checkout page .
any ideas what event i must call . so that it will remove all the products already added to cart ?
Thank you for your response..
I think Magento\Checkout\Model\Cart 's addProduct() is called only when product is added to cart.. how about already added to cart..
For example I add product in cart .. then admin set conditions and here let added product does not satisfy the conditions.. so this product does not get removed .. Magento\Checkout\Model\Cart 's addProduct() is triggered only while adding product to cart