Menu Close
    Searching for an experienced Magento 2 Development Company ?

    How to override phtml file in magento2

    To call your phtml file at place of core(magento’s) file, you need to follow:

    Firstly, create a xml file with the controller name, on which page you want to override.

    For example : here we override checkout/cart/index controller page file.

    create checkout_cart_index.xml inside :

    app/code/Webkul/Hello/view/frontend/layout folder

    <?xml version="1.0"?>
    <page xmlns:xsi=" dc" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceBlock name="checkout.cart">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Webkul_Hello::cart.phtml</argument>


    checkout.cart : is block name, whose template file you want to override.

    Webkul_Hello::cart.phtml : is a template file of your module.

    Now, create cart.phtml file at location:

    app/code/Webkul/Hello/view/frontend/templates folder

    <h1>Shopping Cart</h1>
    //write your stuff here
    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


  • kaushik kumar roy
    But this technique is over riding the template, the products are not displaying. How to over ride the Shopping cart page to add any button or text along with cart products ?.
    • Webkul Support

      You can check our blog
      in this how to add an additional information on checkout page item in described.

      Hope this will help you.

      Thank you.

      Bulbul AgarwalSoftware engineer (Magento)

      Webkul Software Pvt. Ltd. Contact : India (+91)-9650486699 USA (+1)-9143531684

      A 67 Sector 63 ,
      Noida-201301 (U.P.)

      This email and any files transmitted with it are confidential and contain privileged or copyright information. If you are not the intended recipient you must not disseminate, copy, distribute, or use this email or the information contained in it for any purpose other than to notify us. If you have received this message in error, please notify the sender immediately, and delete this email from your system.

  • Maha
    how to override module-customer/view/frontend/templates/widget/name.phtml
    • Webkul Support

      To override this template file, either you have to override the block, or you can create a plugin for the function, in which this block is called.

      Thank you.

  • rajhees
    I want to override register.phtml in magento2 how to do please?
  • Back to Top