WooCommerce: Display Prices Inc + Ex Tax

The WooCommerce settings allow you to show prices including OR excluding tax. But what if we want to show both at the same time e.g. “$100 inc. tax – $89 ex. tax”?

Well, by combining the snippet below with the snippet I already coded for variable products price range, or by installing our Mini/Plugin, you can achieve exactly that.

Yes, in theory you could add a WooCommerce suffix via the settings, but unfortunately WooCommerce wraps such suffix in a “small” HTML tag and therefore the whole content is smaller in size, including the second price.

In this tutorial, we’ll see how to add a suffix via PHP instead, and specifically at how to add the price including tax if your store displays prices excluding tax. Enjoy!

My dev site has the following settings: (1) display prices without tax (2) standard tax rate of 22%. With the snippet below, I’ve managed to add the “ex. TAX – $PRICE inc. TAX” suffix.

PHP Snippet: Display Prices With + Without Tax @ WooCommerce Frontend

/**
 * @snippet       Prices Incl + Excl Tax | WooCommerce Shop
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 7
 * @community     https://businessbloomer.com/club/
 */

add_filter( 'woocommerce_get_price_suffix', 'bbloomer_add_price_suffix_price_inc_tax', 99, 4 );
  
function bbloomer_add_price_suffix_price_inc_tax( $suffix, $product, $price, $qty ){
    $suffix = ' <small>ex. TAX</small> - ' . wc_price( wc_get_price_including_tax( $product ) ) . ' <small>inc. TAX</small>';
    return $suffix;
}

Mini-Plugin: Business Bloomer WooCommerce Display Prices Including and Excluding Tax

You don’t feel confident with coding? You don’t want to purchase yet another bloated, expensive plugin? Great!

Business Bloomer WooCommerce Display Prices Including and Excluding Tax is a mini WooCommerce plugin, without the usual hassles. One feature. Lifetime license. No annoying subscriptions. 1 plugin file. A few lines of code. No banners. No up-sells. No WP notifications. Use it on as many websites as you like. Lifetime support. 1-page documentation. No admin dashboard.

Quick demo:

As you can see the plugin is straight forward. Install it, and automatically see the result on the frontend. Simple!

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce Visual Hook Guide: Single Product Page
    Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can copy/paste). If you like this guide and it’s helpful to you, let me know in the comments! […]
  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages
    I’ve created a visual HTML hook guide for the WooCommerce Archive Page (which is the same page for the Shop, Category, Tag pages). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can […]
  • WooCommerce: Hide Prices on the Shop & Category Pages
    Interesting WooCommerce customization here. A client of mine asked me to hide/remove prices from the shop page and category pages as she wanted to drive more customers to the single product pages (i.e. increasing the click-through rate). As usual, a simple PHP snippet does the trick. I never recommend to use CSS to “hide” prices, […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

12 thoughts on “WooCommerce: Display Prices Inc + Ex Tax

  1. Thanks for the PHP code. This works perfectly!

    I would like to change the font color and size for the prices ex. VAT. This most be bigger and in a different colour then inc. VAT.

    Do you maybe have a CSS code i can use to do this?

    Thanks in advance!

    1. Hey Charissa, if you share one of your product page URLs, I can send you some custom CSS to help you get started

  2. how can this be displayed over two lines please

    1. Just add a “BR” HTML tag in between the two strings

  3. Hi. I add the code but it shows the same price for including and excluding VAT. So it didn’t do calculation based on my VAT rates in Woocommerce settings.

    1. Thanks Davit. You definitely set up taxes properly in the Woo settings?

      1. I have the same problem. I have normal rate and reduced rate.. How can we fix this? 🙂

        1. This is not fixable. Tax calculations are done based on the customer’s billing address (and your tax settings), so if you don’t have geolocation enabled or the current user hasn’t entered any billing information yet, WooCommerce won’t know which tax needs to be applied.

  4. Do you have any quick hook or filter, to implement this on the product edit screen in WP-admin?
    We are adding prices excl. tax to our product edit screen, but it would be nice to show a price calculation next to or below that field which said: Price incl.: xxx.xx – preferably using a JS so it changed on the fly, while editing the regular price.

    1. Hello Roger, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Is it possible to use the Remove Variable Product price range AND put the suffix of Ex VAT on the end of the From: £100.00 price so it is From £100.00 Ex Vat

    or even better to combine both options to then show:
    From £100.00 Ex Vat (£120.00 Inc VAT)

    1. Hi Gerard, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *