8

I'm following https://ranasohel.me/2015/10/02/how-to-overwrite-sales-view-order-phtml-file-in-magento2/

I would like to override magento\vendor\magento\module-shipping\view\adminhtml\templates\order\view\info.phtml

How to do this?

3 Answers 3

6

I've faced the same issue if i refrence to order_info block, you need to reference to order_shipping_view block instead

app/code/Vendor/Module/view/adminhtml/layout/sales_order_view.xml

<?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="order_shipping_view">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Namespace_Module::order/view/info.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

app/code/Namespace/Module/view/adminhtml/templates/order/view/info.phtml

<h1> Override Success </h1>
<h2> Put Your desire content here </h2>

flush magento cache, do setup:upgrade

4

One of the easiest way is that we will create a new backend admin: How to enable custom admin theme in Magento 2.

app/design/adminhtml/{Vendor}/{Theme}/Magento_Shipping/templates/order/view/info.phtml

The second way, set our custom template

app/code/{Vendor}/{Module}/view/adminhtml/layout/sales_order_view.xml

<referenceBlock name='order_info'>
  <arguments>
    <argument name='template' xsi:type='string'>Vendor_Module::order/view/info.phtml</argument>
  </arguments>
</referenceBlock>

Load custom module layout after shipping

app/code/{Vendor}/{Module}/etc/module.xml

<sequence>
        <module name="Magento_Sales"/>
</sequence>
10
  • Does is need to create new theme for this? Can't we override with Magento Default Backend Theme?
    – Jackson
    Commented Nov 30, 2016 at 2:39
  • It depends on your need. If you don't need to create a custom theme, we can choose the second. Commented Nov 30, 2016 at 2:41
  • 1
    Ok I'm using Second Way. sales_order_view.xml is <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="order_info"> <action method="setTemplate"> <argument name="template" xsi:type="string">Custom_Module::order/view/info.phtml</argument> </action> </referenceBlock> </body> </page> Where to put sequence code?
    – Jackson
    Commented Nov 30, 2016 at 2:43
  • In etc/module.xml Commented Nov 30, 2016 at 2:45
  • So my module.xml will be <?xml version="1.0" ?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Custom_Module" setup_version="1.0.1"> <sequence> <module name="Magento_Shipping"/> </sequence> </module> </config>
    – Jackson
    Commented Nov 30, 2016 at 3:07
1

I just ran into this same issue with version 2.3.2. I could not get the above solutions to work for some reason. Finally I just tried copying the full xml from vendor/magento/module-shipping/view/adminhtml/layout/sales_order_view.xml to my own extension app/code/Vendor/Module/view/adminhtml/layout/sales_order_view.xml

You then just need to copy the template file Magento_Shipping::order/view/info.phtml and move it to you custom extension and make the changes you need.

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.