3

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

2

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

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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