0

Magento2 How can I display product Added to cart success message under Add to cart button on product details page?

3
  • you can move default page message to below add to cart button only for catalog_product_view.xml
    – Pawan
    Oct 16, 2020 at 6:55
  • Thanks for advice..
    – Arjun
    Oct 16, 2020 at 7:11
  • welcome..... :)
    – Pawan
    Oct 16, 2020 at 7:21

2 Answers 2

1

Posting answer might be helpful for some one.

<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" after="product.info.addtocart" />
    </body>
</page>

In catalog_product_view.xml

0

First of all, you need to override the vendor catalog_product_view.xml file in your theme. if it does not exist in your theme that i have given below or this file already exists in your theme so just add the given below code on the body tag.

vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml

to

app/design/frontend/[Vendor]/[MyCustomTheme]/Magento_Catalog/layout/catalog_product_view.xml

<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.addtocart" />
    </body>
</page>

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.