Home » WooCommerce: Add Prefix / Suffix to Product Prices

WooCommerce: Add Prefix / Suffix to Product Prices

by Tutor Aspire

Sometimes you may want to add a prefix or a suffix to your prices. It could be something like “From…”, “Only…”, “…tax free” and so on.

The first good news is this is very easy to do with a WooCommerce filter (remember, filters change the value of an existing variable, while actions add content). The second good news is that you don’t need to know PHP, just copy/paste my snippet!

woocommerce-add-prefix-suffix-price
WooCommerce: add prefix & suffix to product prices

WooCommerce Settings: Add Suffix to Prices

Did you now there is a handy setting under WordPress Dashboard > WooCommerce > Settings > Tax > Tax Options > “Price display suffix”? Cool.

You can also use two placeholders: {price_including_tax} and {price_excluding_tax}. Which means, you can use this setting alone (and no coding) to show something like:

In the image example, I’m using “ex VAT {price_including_tax} inc VAT” in the WooCommerce settings as suffix. Easy peasy!

The only problem is in the display – WooCommerce suffix is wrapped in a “small” HTML tag, and therefore the whole “ex VAT {price_including_tax} inc VAT” string is smaller in font size than the price. This is why PHP is more useful than WooCommerce product price suffix settings in this case…

PHP Snippet: Add Suffix to WooCommerce Prices

/**
 * @snippet       Adds suffix to WooCommerce prices
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */
  
add_filter( 'woocommerce_get_price_suffix', 'tutoraspire_add_price_suffix', 99, 4 );
 
function tutoraspire_add_price_suffix( $html, $product, $price, $qty ){
    $html .= ' suffix here';
    return $html;
}

PHP Snippet: Add Prefix to WooCommerce Prices

And if you wish to prepend some text or dynamic content before prices, here’s a way to add a prefix as well.

/**
 * @snippet       Adds prefix to WooCommerce prices
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */
  
add_filter( 'woocommerce_get_price_html', 'tutoraspire_add_price_prefix', 99, 2 );
 
function tutoraspire_add_price_prefix( $price, $product ){
    $price = 'Prefix here ' . $price;
    return $price;
}

Is There a Plugin For That?

If you’d love to code but don’t feel 100% confident with PHP, I decided to look for a reliable plugin that achieve the same result.

As usual, I’ve chosen a WooCommerce plugin vendor based on marketplace reputation, dedicated support quality, code cleanliness, long-term reliability and – probably almost as importantly – where the “people behind” the plugin are active supporters of the WordPress ecosystem.

And in this case, price suffix is one of the features of WooCustomizer, a plugin built for everyone who wants to fully customize their WooCommerce store without coding (e.g. edit buttons, badges, tabs, pages, stock display, checkout fields).

But in case you hate plugins and wish to code (or wish to try that), then keep reading 🙂

You may also like