문제

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