1

How can I move the add to cart button immediately below the price in Magento 2? I presume it's an XML update but I am unsure of the code required.

I want to move it from under the description to above the description.

2

copy "catalog_product_view.xml" file to your theme.

vendor/magento/module-catalog/view/frontend/layout/

to

app/design/frontend/{{vendortheme}}/{{theme}}/Magento_Catalog/layout

add below tag in body

<move element="product.info.addtocart" destination="product.info.price"  after="-" />

catalog_product_view file like

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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="product.info.addtocart" destination="product.info.price" after="-"/>
    </body>
</page>
  • I have applied the change in the file... redeployed static and cleared cache... but the page doesn't update. Any further advise please? – YorkieMagento Nov 17 at 13:42
  • did you override catalog_product_view.xml file in your theme or custom module – Monarch Nov 17 at 15:40
  • Got it working Monarch. It seemed to be that I had to rm some of the var/ files. They must have been caching a layout element? – YorkieMagento Nov 28 at 14:13
1

You need to add below code in catalog_product_view.xml file under

app/design/frontend/Vendor/Theme/Magento_Catalog/layout/catalog_product_view.xml

<move element="product.info.addtocart" destination="product.info.main" after="product.info.price"/>

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.