Magento – Magento 2: How to move the tier price table under the quantity input box on product view page

addtocartcustom-templatemagento2

I am working on the product catalog page using my customized theme. Is it possible to insert my customized tier_prices.phtml inside my customized addtocart.phtml file? I need to put my tier prices table under the qty input box.

This is what I want to accomplish

This is what I want to accomplish

This is the screenshot of html codes for each block ( tier_prices and addtocart). Thanks.

Please help. Thanks.

Best Answer

Go to below location

Magento_root/vendor/magento/module-catalog/view/frontend/templates/product/view

Copy file with Name addtocart.phtml & paste it to below location in your theme

Magento_root/app/design/frontend/{Package}/{theme}/Magento_Catalog/templates/product/view

Put the below code into after the Qty box. You will find qty box code in the file.

<?php echo $this->getLayout()
          ->createBlock('Magento\Catalog\Pricing\Render',
                  "product.price.tier",
                    [
                        'data' => [
                            'price_render' => 'product.price.render.default',
                            'price_type_code' => 'tier_price',
                            'zone' => 'item_view'
                        ]
                   ]
                  )
          ->toHtml();?>

Now go to the below location

Magento_root/app/design/frontend/Package/theme/Magento_Catalog/layout/

Put the below code into the file with name 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>
         <referenceBlock name="product.price.tier" remove="true"/>
    </body>
</page>

Note: Put your cache disabled or run the below command while you are doing this changes

php bin/magento cache:flush