2

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.

  • could you share you page URL to inspect – Manoj Deswal Oct 10 '17 at 9:15
  • im still working on my localhost. i'll update my post to include screenshots of html codes.thanks. – liani.kismet Oct 11 '17 at 7:41
  • try with <move element="product.price.tier" destination="product.info.form.content" after="product.info.addtocart" /> – Rakesh Jesadiya Oct 11 '17 at 8:43
  • it didn't work since the Add to Cart button is inside the block "product.info.addtocart" and i want to put the block "product.price.tier" between the Qty input box and Subtotal. i also tried including the tier_prices.phtml within addtocart.phtml using the "<?php include ($block->getTemplateFile(...)) ?>" command but got some errors. – liani.kismet Oct 12 '17 at 6:42
1

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

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.