cancel
Showing results for 
Search instead for 
Did you mean: 

Override module-tax\Block\Sales\Order\Tax.php

Override module-tax\Block\Sales\Order\Tax.php

How can I override the Tax.php file at vendor/magento/module-tax/Block/Sales/Order/Tax.php?

 

I've tried di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Tax\Block\Sales\Order" type="DigitalStartup\EmailTax\Tax" />
</config>

But I get the error:

Class 'Magento\Tax\Block\Sales\Order\Tax' not found in vendor/magento/module-sales/Block/Adminhtml/Order/Totals/Tax.php.

What do I need to use to override the file?
Thank you.

2 REPLIES 2

Re: Override module-tax\Block\Sales\Order\Tax.php


It seems as if you have forgotten to add "\Tax" in the section.
Check the location of the di.xml file and make sure that the di.xml file is not located in the adminhtml folder as you are trying to override the file that affects the frontend.

I hope it helps
Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: Override module-tax\Block\Sales\Order\Tax.php


@Sanjay Jethva wrote:

It seems as if you have forgotten to add "\Tax" in the section.
Check the location of the di.xml file and make sure that the di.xml file is not located in the adminhtml folder as you are trying to override the file that affects the frontend.

I hope it helps

Thanks for the info, much appreciated!