2

I'm trying to override the vendor/magento/module-customer/view/frontend/templates/address/edit.phtml with a custom one but I can't get it to work.

The stock address/edit.pthml gets loaded in vendor/magento/module-customer/view/frontend/layout/customer_address_form.xml.

My custom customer_address_form.xml located at /home/roy/www/dremelonline/web/vendor/activeants/magento2-checkoutchanges/src/view/frontend/layout/customer_address_form.xml looks like this:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <referenceBlock name="customer_address_edit">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Roy_CheckoutChanges::edit.phtml</argument>
                </action>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>

My custom edit.phtml file is located in vendor/roy/magento2-checkoutchanges/src/view/frontend/templates/edit.phtml

My module.xml looks as following:

<module name="Roy_CheckoutChanges" setup_version="1.0.0">
    <sequence>
        <module name="Magento_Checkout"/>
        <module name="Magento_Customer"/>
        <module name="Roy_Base"/>
    </sequence>
</module>

I've flushed my cache and I have ran the upgrade command.

According to reading other posts about related problems, this code should work, but as you already know, it doesn't :p

Thanks!

1 Answer 1

2

Add this code into your custom module etc/module.xml

<sequence>
       <module name="Magento_Checkout"/>
</sequence>

customer_address_form.xml :

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
    <referenceContainer name="content">
          <block name="customer_address_edit">
               <action method="setTemplate">
                    <argument name="template" xsi:type="string">Roy_CheckoutChanges::edit.phtml</argument>
               </action>
           </block>
       </referenceContainer>
   </body>

6
  • It should be 'Magento_Customer` since I'm overriding the customer module right? Anyways, I already got Magento_Checkout and Magento_Customer in my sequence list!
    – Roy van Os
    Nov 23, 2016 at 12:22
  • yes, you should add module name which you want to override. Nov 23, 2016 at 12:22
  • clear cache and flush Nov 23, 2016 at 12:23
  • I forgot to mention that, I've already flushed my cache and I've ran the upgrade command.
    – Roy van Os
    Nov 23, 2016 at 12:27
  • 1
    check answer again. Nov 23, 2016 at 12:32

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.