68
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, 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!
PHP Snippet: Display Prices With + Without Tax @ WooCommerce Frontend
/**
* @snippet Prices Incl + Excl Tax | WooCommerce Shop
* @how-to Get tutoraspire.com FREE
* @author Tutor Aspire
* @compatible WooCommerce 6
* @donate $9 https://tutoraspire.com
*/
add_filter( 'woocommerce_get_price_suffix', 'tutoraspire_add_price_suffix_price_inc_tax', 99, 4 );
function tutoraspire_add_price_suffix_price_inc_tax( $suffix, $product, $price, $qty ){
$suffix = ' ex. TAX - ' . wc_price( wc_get_price_including_tax( $product ) ) . ' inc. TAX';
return $suffix;
}