0

I have a problem when customising the Add to cart success message in Magento.

When hiding the success message element all success messages when adding to cart will be hidden (I try to add a class to message to hide it)

But on the Product Page I want the success message for the main Product to be displayed on successful add to cart and not ti display when adding Related Products to your cart.

So how can I know where the "Add to Cart" action was called from or some solution for this?

enter image description here

0

1 Answer 1

2

If you want to hide the message when Product add to cart

you just need to go to given file

vendor\magento\module-checkout\Controller\Cart\Add.php

There are all the messages in that file you just need to comment the line whatever message you need to hide.

3
  • They only want to hide it when adding a related item, they still want it to display when adding the main product. It could technically be done with an override of the AddAction however i think something would need to be posted from the frontend too, eg product type main product or related product
    – DanCarlyon
    Mar 16, 2018 at 10:31
  • 1
    pass the extra parameter whenevr related product will add to cart and compare that value in controller if found than not display message. it solved your problem Mar 16, 2018 at 10:33
  • @jigsparmar, I found solution for that. It's same with you. Add a param in form related and check in Controller to change the param output. Thank so much.
    – ATT
    Mar 16, 2018 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.