Blog

How to Remove WooCommerce Tax Labels

This Ask SkyVerge question comes from Flora:

Can I remove the “ex. tax” label that appears in the order details on invoices? I don’t need it to say this after prices.


Shops that typically sell items excluding tax don’t require a notice that pricing is excluding tax, especially if the invoice contains a tax line item. For example, in the US, subtotals are usually displayed exclusive of tax, then tax is included as a line item on invoices. As a result, stores that sell only within the US don’t typically need this label in email invoices.

Removing the WooCommerce tax label, i.e. “(ex. tax)”, is simple, though it requires a tiny bit of sleuthing to find where to change it. We’ll be removing it from the “Order Details” table included in all emails:

WooCommerce (ex. tax) labels

WooCommerce (ex. tax) labels

You’d think it’s as easy as overriding the email template, but it’s not 🙂 . We have to go through a bit of a rabbit hole to figure out where that “(ex. tax)” label is coming from.

First, we find that the order totals are generated from the get_order_item_totals() function in the email template itself. We can’t remove this from the template, as it adds both the amount for the subtotal (which we need to keep) and the label. We won’t be able to change the WooCommerce tax label here, but let’s find that function in the core code to see if we can change what’s returned for the label.

When we explore the get_order_item_totals() function, we can see that it’s made of several parts. The subtotal and its label aren’t generated here, but the subtotal is displayed by the get_subtotal_to_display() function, so that must be what we want to examine more closely.

When we do, we’re able to finally see where that tax label comes into play, as it’s generated as part of the get_subtotal_to_display() function. The function gets the value for the subtotal, and the subtotal will be formatted with an excluding tax label if prices are displayed excluding tax.

We see that the label is generated in this function from another function: the ex_tax_or_vat() function. When we take a look at this function, we finally find a filter that we can use to change the label that’s returned.

The woocommerce_countries_ex_tax_or_vat filter generates the label used in subtotal, tax-exclusive display, which in turn is used in all email templates. We can use this filter to change the label pretty easily with this code snippet in our custom plugin or functions.php:

function sv_change_email_tax_label( $label ) {
    $label = '';
    return $label;
}
add_filter( 'woocommerce_countries_ex_tax_or_vat', 'sv_change_email_tax_label' );

Now the order details table will return only amounts without a label included to indicate that prices are displayed exclusive of tax:

woocommerce tax label removed

ex. tax label removed

Whew! Definitely more than you probably bargained for, but sometimes this is how WooCommerce works. Breaking up functions like this ensures that they can easily be used in different contexts, but it can make it tricky to see where a label or value comes from sometimes. Following this trail through the subtotal eventually gave us the filter we needed to remove the WooCommerce tax label, and you can typically use this technique with many WooCommerce changes.

3 Comments

  • Patrick Gilmour 2 years ago Reply

    Learning these Sherlock techniques is really useful. Another great tutorial – thanks!

  • dennis 2 years ago Reply

    Hello,
    Thank you Beka, for this useful information. Can you help me make “subtotal” line disappear completely in WC e-mail notifications?
    Thanks,

  • Darren 2 years ago Reply

    Hey Beka, thanks for the great tutorial! I think this will be helpful in trying to do something similar.

    I’m trying to make it so that only ex. tax figures show in the subtotal, even though the WC cart and products show inc. tax. Can you suggest how to do this?

    Thanks!

Submit a Comment