I have to add block and call custom phtml file after "Add to Cart" button on product details page.
I have added below code in catalog_product_view.xml file in extension.
It is working but displaying before Qty input box
<?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>
<referenceContainer name="alert.urls">
<block class="Package_Name\Module_Name\Block\Catalog\Product\View\Enquiry" name="product.info.enquiry" template="Package_Name_Module_Name::catalog/product/view/enquiry.phtml" after="-" />
</referenceContainer>
</body>
But it's not working
<?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">
<block class="Package_Name\Module_Name\Block\Catalog\Product\View\Enquiry"name="product.info.enquiry" template="Package_Name_Module_Name::catalog/product/view/enquiry.phtml">
</block>
</referenceBlock>
<!-- for config products -->
<referenceBlock name="product.info.addtocart.additional">
<block class="Package_Name\Module_Name\Block\Catalog\Product\View\Enquiry" name="product.info.enquiry" template="Package_Name_Module_Name::catalog/product/view/enquiry.phtml">
</block>
</referenceBlock>
</body>
Best Answer
Use below step to add block/template below the Add to Cart button
Create file in your module/theme catalog_product_view.xml
and add below code