I want to add product to cart. So when i click on the add to cart
button i will be checking some condition like some variable is set or not. If it is set, product will be added to cart. If not set, the product should not be added to cart.
for this i was using observer called controller_action_predispatch_checkout_cart_add
I can wrote a condition to check variable is set or not.if it is not set i want to come out of the observer. I mean product should not added to cart.
Please Help Me.
Thanks In Advance
Best Answer
The closest events I could find that would work that are lower than the dispatch event are
You can have an event listener on one of those events that does your logic check and throws an exception if it fails.
That being said, Magento itself actually uses the following event
Then, in the listener is uses code like this