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-pricewoocommerce-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!

PHP Snippet: Add Suffix to WooCommerce Prices

/**
 * @snippet       Adds suffix to WooCommerce prices
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
  
add_filter( 'woocommerce_get_price_suffix', 'bbloomer_add_price_suffix', 99, 4 );
 
function bbloomer_add_price_suffix( $html, $product, $price, $qty ){
    $html .= ' suffix here';
    return $html;
}

PHP Snippet: Add Prefix to WooCommerce Prices

/**
 * @snippet       Adds prefix to WooCommerce prices
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.8
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
  
add_filter( 'woocommerce_get_price_html', 'bbloomer_add_price_prefix', 99, 2 );
 
function bbloomer_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 reliable plugins that achieve the same result. As usual, I’ve chosen WooCommerce plugin vendors 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.

1. WooCustomizer

Sold by: WooCustomizer – Developed by: Zack Viljoen – 14 Day Money Back Guarantee

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).

Share:

Leave a Reply