0

I want to add a block after add to cart but this code doesn´t work:

app/design/frontend/Mgs/claue/Magento_Catalog/layout/catalog_product_view.xml
    
<block class="Magento\Catalog\Block\Product\View" name="product.info" template="product/view/form.phtml">
    <container name="product.info.form.content" as="product_info_form_content">
           <block class="Magento\Catalog\Block\Product\View" name="product.info.addtocart" as="addtocart" template="product/view/addtocart.phtml"/>
           
           <!--THIS BLOCK--> 
           <block class="Magento\Catalog\Block\Product\View" name="custom.cuidados" template="Magento_Catalog::product/view/cuidados.phtml"/> 
           <!--===========-->

    </container>

</block>

What is the problem??

Thankss

2 Answers 2

1

app/design/frontend/Mgs/claue/Magento_Catalog/layout/catalog_product_view.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. 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>
            <referenceContainer name="product.info.main">
                 <block class="Magento\Catalog\Block\Product\View" name="custom.cuidados" template="Magento_Catalog::product/view/cuidados.phtml"/>
            </referenceContainer>

        <move element="custom.cuidados" destination="product.info.main" before="product.info.extrahint"/>
    </body>

</page>

Hope this will help you..!

0

You can add following code in your theme file : app/design/frontend/Mgs/claue/Magento_Catalog/layout/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>
        <!-- another code lines -->
        <referenceContainer name="product.info.form.content">
            <block class="Magento\Catalog\Block\Product\View" name="custom.cuidados" template="Magento_Catalog::product/view/cuidados.phtml" after="product.info.addtocart"/>
        </referenceContainer>
    </body>
<page>

Thank you Hiren Patel

1
  • I've tried but it doesn't work. The code does not appear on the product page. What could be happening? Sep 30, 2020 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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