0

Simple issue :

This is one of magento template core file : vendor/magento/module-sales/view/adminhtml/templates/order/totals.phtml

How can I overide it ?

I tried to create this one but it failed

app/code/Cpy/Sales/view/adminhtml/templates/order/totals.phtml

I guess I can't just use a preference like I'm doing with class.

2

The template file path is associated to the block in layout xml files. So even if you create a new template file(.phtml), you need to override the appropriate layout xml and provide the path of new template file to be used. In your case you have to create two files in new module.

1. app/code/Cpy/Sales/view/adminhtml/templates/order/totals.phtml - updated phtml

2. app/code/Cpy/Sales/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_totals">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Cpy_Sales::order/totals.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

Hope it was helpful.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.