4

How to move Add to cart success and error message above Add to cart button and not at the top ?

2 Answers 2

3

You could do it by the layout. I didn't test it but it should work.

Create catalog_product_view.xml in your theme and add

<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="page.messages" destination="product.info.form.content" before="product.info.addtocart" />
    </body>
</page>
1
  • it's not working for me M 2.3.4, the message has gone after that Apr 20, 2020 at 11:21
1

Vendor\Module\view\frontend\layout\catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="page.messages" destination="product.info.form.content" as="page.messages" after="addtocart"/>
    </body>
</page>
1
  • it's not working for me M 2.3.4, the message has gone after that Apr 20, 2020 at 11:22

Your Answer

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

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