How To Add Currency Code As Suffix To Prices In WooCommerce

WooCommerceIf you’re looking for a way to modify the price so that your currency code becomes a suffix to your prices in WooCommerce you’ve come to the right code snippet tutorial.

I’m going to show you how to make prices that look like this:


Into this:

$49 AUD

When I was relaunching my site for ThirstyAffiliates we brought the shopping cart experience home with WooCommerce.

During the process I changed my pricing to AUD (Australian Dollars) but because the currency symbol ($) is the same as USD I thought it might cause some confusion if the first place they saw AUD was in PayPal when they got through to process their payment.

I’ve written previously about changing the currency symbol in WooCommerce to include your currency code, but it leaves the prices looking a little unnatural like this “AUD$49”.

The first step is easy enough, create a function to filter the price format in WooCommerce.

WooCommerce makes this ridiculously easy with it’s ample hooks and filters API, we just jump into the “woocommerce_price_format” action.

Here’s the code snippet which will add the suffix to all your prices throughout the site (copy and paste into your functions.php):

function addPriceSuffix($format, $currency_pos) {
	switch ( $currency_pos ) {
		case 'left' :
			$currency = get_woocommerce_currency();
			$format = '%1$s%2$s ' . $currency;
	return $format;
add_action('woocommerce_price_format', 'addPriceSuffix', 1, 2);

I also wanted the ability to just show the currency code suffix on prices in the cart and checkout pages, leaving my product pages and listings all unaffected.

To do this you need to wrap this add_action with another function that only gets called on those pages.

We use two new actions to call our function to add the action for modifying the price format. Tricky stuff!

Here’s the full code snippet for restricting the formatting to cart and checkout (copy and paste into your functions.php):

function addPriceSuffix($format, $currency_pos) {
	switch ( $currency_pos ) {
		case 'left' :
			$currency = get_woocommerce_currency();
			$format = '%1$s%2$s ' . $currency;
	return $format;
function addPriceSuffixAction() {
	add_action('woocommerce_price_format', 'addPriceSuffix', 1, 2);
add_action('woocommerce_before_cart', 'addPriceSuffixAction');
add_action('woocommerce_review_order_before_order_total', 'addPriceSuffixAction');

Hope this helps you, if it does feel free to leave a comment 🙂

Looking for a coding job? See our job listings page. Click here to view →

About Josh Kohlbach

Josh is a programmer, entrepreneur and the founder of Code My Own Road. He started this website to help programmers with business stuff and also to get things straight in his head. You can read more about Code My Own Road and Josh on the About page

, , ,

20 Responses to How To Add Currency Code As Suffix To Prices In WooCommerce

  1. Andy July 25, 2013 at 9:09 am #

    Perfect! I needed a way to show the base currency when using the Currency Converter plugin. The first snippet worked like a charm. Thanks for the post!

    • Josh Kohlbach July 25, 2013 at 9:11 am #

      Glad it hit the nail on the head Andy 🙂

  2. David September 13, 2013 at 2:03 am #

    Awesome. Thanks so much for the post Josh! I have another problem, is there any way to have three decimal places for product prices but have only two for subtotal and total?

  3. Jovan September 21, 2013 at 2:27 am #

    How can I get the float value of the price without currency symbol and the currency code?

    • Josh Kohlbach September 24, 2013 at 9:51 am #

      Hey Jovan,

      In this snippet or just in general?

      In this snippet just replace the format line with
      $format = '%1$s%2$s';

      Otherwise you can use get_product() from the WooCommerce API then on that object use the get_price() function or get_price_html() if you want HTML formatted.

  4. Pat Skot October 25, 2013 at 7:51 am #

    Nice one, you just saved me a lot of time! Thank you.

    • Josh Kohlbach October 25, 2013 at 8:27 am #

      No worries Pat 🙂

  5. Miro January 19, 2014 at 3:41 am #

    Thanks for this it is almost what I am looking for 🙂

    I applied your code so I got this €9,99 EUR. But is there a way to change it to 9,99 €?

    I tired your advice to Jovan but this did not help.

    Thank you for help.

    • Josh Kohlbach January 19, 2014 at 10:57 am #

      Hey Miro,

      You probably want to change the setting in the backend of Woo to use right hand side currency, then in the code above use case ‘right’ instead of left. After that follow the rest of the instructions, but alter the format to

      $format = '%2$s%1$s ' . $currency;
  6. Jo March 14, 2014 at 1:37 pm #

    Thanks, that first snippet worked perfectly to add AUD to all prices in my store and saved me heaps of time looking it up. Appreciate your article!

    • Josh Kohlbach March 14, 2014 at 1:50 pm #

      No worries Jo, glad you found it helpful.

  7. Paul July 3, 2014 at 8:46 pm #

    Hi Josh,

    Thank you very much for the snippets, they are exactly what I needed.

    If I may ask for your help. I have one issue on my checkout page. The AUD is showing after the prices when the page loads, but as soon as the cart totals finish loading (little spinning wheel) the AUD disappears. I am using the first snippet as I want the currency to be shown on all product areas.

    Thank you very much again and I appreciate any help or suggestions.

  8. Jacqui September 25, 2014 at 4:13 pm #

    Thankyou! Just what I was after. I used the second snippet and it worked perfectly.

  9. Shawn September 30, 2014 at 10:44 am #

    Thanks! Exactly what I was looking for!

  10. Willy Y October 11, 2014 at 1:05 pm #

    Perfect…exactly what I needed. 1 question…is there an easy way to make this currency symbol appear in a smaller font size than the price itself?

    • Josh Kohlbach October 14, 2014 at 12:16 pm #

      Hi Willy Y,

      This would have to be done in CSS, you could wrap the symbol in a tag with a special class on it though.

      Hope this helps point you in the right direction.


  11. Growstudio July 3, 2015 at 5:24 am #

    Great, you rulz. Works at 100%, thanks for share.

  12. Al August 19, 2015 at 4:31 pm #

    Hi Josh,

    I couldn’t get this to work with the code you provided. Should the above code work as is without using your first method (I have your first method working btw). I also tried changing the WooCommerce setting for right side currency but still no change, the area is just blank without using the first method.

    BTW, I’m using version 2.3.8

    If you could help me out that would be terrific, thanks.

  13. Sally November 10, 2015 at 4:25 am #

    Exactly what I was looking for. Thanks!

  14. Zee June 10, 2016 at 11:27 am #

    Unfortunately it not working or me.
    Probably is the updated Woocommerce

Leave a Reply

Read more:
Combatting Spam in WordPress

I've just done something I was hoping to avoid on my blog. I disabled comments for any post older than...