سؤال

I want to display my custom template just before add to cart button on product detail page.

It should be display in all type of product like Bundle, Grouped, Configurable Product.

Thanks

هل كانت مفيدة؟

المحلول

I have got solution by core layout reference, I have displayed my custom template just before add to cart button in all types of product by below code

app/code/Namespace/MyModule/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="product.info.addtocart">
            <block class="Magento\Catalog\Block\Product\View" name="product.custom.simple" template="Namespace_ModuleName::product/view/custom.phtml" />
        </referenceBlock>
        <referenceBlock name="product.info.addtocart.additional">
            <block class="Magento\Catalog\Block\Product\View" name="product.custom.additional" template="Namespace_ModuleName::product/view/custom.phtml" />
        </referenceBlock>
    </body>
</page>

app/code/Namespace/MyModule/view/frontend/layout/catalog_product_view_type_bundle.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.info.addtocart.bundle">
            <block class="Magento\Catalog\Block\Product\View" name="product.custom.bundle.additional" template="Namespace_ModuleName::product/view/custom.phtml" />
        </referenceBlock>
    </body>
</page>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top