I wanted to override the content of addtocart.phtml which is located in


Now I want to modify the content of this and add this to my custom module located in


But my changes does not appear. Is my path wrong? What or where should I place the custom addtocart.phtml file?

2 Answers 2


You have to override in to your theme to below path:


if you make addtocart.phtml in your custom module like


you need to change catalog_product_view.xml layout too


if you want to override core template in your custom module then you have to create that particular layout file and write a code of "setTemplate" as below:


<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="product.info.addtocart">
            <action method="setTemplate">
           <argument name="template" xsi:type="string">Package_Module::product/view/addtocart.phtml</argument>

Then you can create a file inside your module according to a path defined in


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.