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.

4
  • could you share you page URL to inspect Oct 10, 2017 at 9:15
  • im still working on my localhost. i'll update my post to include screenshots of html codes.thanks. Oct 11, 2017 at 7:41
  • try with <move element="product.price.tier" destination="product.info.form.content" after="product.info.addtocart" /> Oct 11, 2017 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. Oct 12, 2017 at 6:42

1 Answer 1

2

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 and acknowledge you have read our privacy policy.

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