How to extend core templates in Magento 2

by Karts   Last Updated July 17, 2017 10:09 AM

How to extend vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml so I can add another button to it?

I tried it by creating my own module and copied the above file to app/code/"vendorname"/"modulename"/view/frontend/templates/form.phtml and created an xml file app/code/"vendorname"/"modulename"/view/frontend/layout/checkout_cart_index.xml that has the following content:

               <referenceBlock name="checkout.cart">
                    <action method="setTemplate">

                         <argument name="template" xsi:type="string">Rampart_Core::form.phtml</argument>

                    </action>
               </referenceBlock>

But it override the cart page and display only a portion of the original-cart page whereas I want to add button to existing cart page.



Answers 1


This is simple to extend form.

Here you can extend: vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml

Extend it same: app/design/frontend/VENDOR/Theme_Name/Magento_Checkout/templates/cart/form.phtml

-- you only need to update :VENDOR/Theme_Name

This is suffice if you only to update button in form.phtml and there is no need to extend/overwrite module for it.

Jai
Jai
July 17, 2017 09:36 AM

Related Questions


Override / Extend a core class

Updated August 16, 2017 14:09 PM

Extend less of Catalog

Updated April 27, 2016 09:03 AM

Magento 2 how to extend core module

Updated February 21, 2016 01:04 AM

Modifying authentication popup

Updated July 21, 2016 08:03 AM

How to extend css of theme

Updated September 09, 2016 08:05 AM