Do you want to remove the “ex. tax” label that appears in the order details on invoices?
In this brief tutorial, I will walk you through how to hide the tax label.
If your WooCommerce store sells items excluding tax, you do not require a notice that pricing is excluding tax, especially if the invoice contains a tax line item.
WooCommerce Hide Tax Label
In the US, subtotals are usually displayed exclusive of tax.
The tax is included as a line item on invoices.
This means that stores that sell only within the US do not typically need this label in email invoices.
It is very easy to hide the WooCommerce tax label, i.e. “(ex. tax)”, if you are familiar with PHP code.
Hiding the Tax Label in WooCommerce
The first thing is to figure out where that “(ex. tax)” label comes from by analyzing the functions.
The order totals are generated from the get_order_item_totals() function in the email template itself. Therefore, we cannot remove this from the template. This is because it adds both the amount for the subtotal and the label.
Moreover, we will not be able to change the WooCommerce tax label here. However, we can find the core code’s function to see if we can change what is returned for the label.
The get_order_item_totals() function is made up of several parts. It is worth mentioning that the subtotal and its label aren’t generated here, but the subtotal is displayed by the get_subtotal_to_display() function.
The tax label is generated as part of the get_subtotal_to_display() function. This function gets the subtotal value, and the subtotal will be formatted with an excluding tax label if prices are displayed, excluding tax.
The label is generated in this function from another function called the ex_tax_or_vat() function. The next step is to create a filter that we can use to change the returned label. We can modify it to hide the tax label.
The woocommerce_countries_ex_tax_or_vat filter generates the label used in the subtotal, tax-exclusive display. Therefore, it is used in all email templates.
Steps to Hide the Tax Label in WooCommerce
Here are the steps you need to follow to hide the tax label.
- Log into your WordPress site and access the Dashboard as the admin user.
- From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to add the function to hide the tax on the checkout page if the field value exists.
- Add the following code to the functions.php file:
function njengah_change_email_tax_label( $label ) { $label = ''; return $label; } add_filter( 'woocommerce_countries_ex_tax_or_vat', 'njengah_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:
Conclusion
This post shares how you can easily remove the “(ex. tax)” label that appears in the order details on invoices.
Moreover, breaking up functions ensures that they can easily be used in different contexts. However, it can be a little bit tricky to see where a label or value comes from sometimes. You can typically use this technique with many WooCommerce changes, as I have illustrated in this article.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- How to Hide Best Sellers WooCommerce Storefront FrontPage
- How to Add Search Box on Top of Page Storefront Theme
- How to Redirect User If Not Logged in WordPress » Page Redirect
- How to use WordPress Custom Hooks do_action & apply_filters With Examples
- How to Logout without Confirmation: How to Remove “Are you sure you want to log out?”
- How to Check If Plugin is Active In WordPress [ 3 WAYS ]
- How to Hide Read More and Add to Cart Button WooCommerce
- How to Add WooCommerce Storefront Product Pagination
- How to Add WooCommerce Storefront Sitemap
- How to Simplify Checkout Free Items Storefront Theme
- How to Add WooCommerce Storefront Hero Image
- How to Move Primary Menu Storefront WooCommerce
- How to Hide All Products From Shop Page in WooCommerce
- How to Setup WooCommerce Storefront Blog
- How to Hide Quantity In Stock In WooCommerce
- How to Hide Shipping Methods for Certain Conditions
- How to Display Category Names in WordPress Using a Practical Example
- How to Hide Errors From Visitors WooCommerce
- How to Display All Products Purchased by User – Purchase History