I want to remove the Success message when adding to cart. Right now when you click on the Add to Cart
button it displays a message of Successfully added <product> to cart
but I don’t want to display this. Is there a way to achieve this?
I want to remove the Success message when adding to cart. Right now when you click on the Add to Cart
button it displays a message of Successfully added <product> to cart
but I don’t want to display this. Is there a way to achieve this?
3
Answers
Achieving this is rather easy. Create a basic module under
app/code/<vendor>/<module>
with/registration.php
/etc/module.xml
Now the way you can remove the Add to Cart Message is to watch it’s observable event and remove it after dispatch. Create
/etc/events.xml
with following content:So when
checkout_car_add_product_complete
is dispatched, the observerAfterAddToCart
is called. Create it like this:That’s it. Add to Cart Message will not be displayed anymore, while all other messages like Add to Compare etc. will still be displayed.
This solution is not mine originally but I can’t remember where I found it.
<preference for="MagentoCheckoutControllerCartAdd" type="<Vendor><Module>ControllerCartAdd"/>
execute()
You have to add
afterExecute
plugin toMagentoCheckoutControllerCartAdd
class: