0

I want to hide tax details from order_email_template in Magento-2.1. For comment this code in \vendor\magento\module-sales\view\frontend\layout\sales_order_email_items.xml:

<block class="Magento\Tax\Block\Sales\Order\Tax" name="tax" template="order/tax.phtml">
    <action method="setIsPlaneMode">
        <argument name="value" xsi:type="string">1</argument>
    </action>
</block>

I want to override it. Please help me to override this file.

2 Answers 2

3

Core file override steps:

Step1: First copy core file sales_order_email_items.xml & past in your theme at location

app/design/frontend///Magento_Sales/layout/

Step : 2 Add Remove block code in file

<?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" label="Email Order Items List" design_abstraction="custom">
    <body>
        <referenceBlock name="tax" remove="true"/>
    </body>
</page>

Step: 3 After run below commands

php bin/magento cache:clean

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy

3
  • I will run same steps,but it is not working. Oct 10, 2018 at 13:44
  • Updates ans pls check & let me know
    – Abdul
    Oct 10, 2018 at 13:50
  • Please note that the file to modify in Magento 2.3 is sales_email_order_items.xml
    – PauGNU
    May 25, 2020 at 10:59
2

Additionally to the best answer: That solution may not be good. Magento calculates subtotal and taxes. When you remove block from layout it will not update totals. see \Magento\Sales\Block\Order\Totals::_beforeToHtml $child->initTotals(); So the subtotal may be decreased on tax amount, and will present a netto price. You'd better use this approach to avoid unexpected behavior.

<referenceBlock name="tax" display="false"/>

The subtotal will be processed, but the block will not be rendered.

For more info see:

\Magento\Framework\View\Element\AbstractBlock::getChildHtml \Magento\Framework\View\Layout::renderElement

1
  • Your solution suits perfectly to my requirements. Thank you.
    – Silver
    Aug 4, 2021 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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