Display Currency Code Infront of Symbol in WooCommerce

WooCommerce has a ton of options for multiple currencies right out of the box. WooCommerce comes bundled with dozens of different currencies you can use in your store, there are snippets to add extra currencies,ย there's also have a really nice Currency Converter Widget to help you display different currencies in your store.

By default WooCommerce will display the currency symbol with the product. You can do all sorts of things like choosing the position of the symbol (some currencies the symbol goes on the right of the number), you can change the decimal separator (some currencies prefer commas to decimal points), and you can change the number of decimal places (some currencies like Yen don't have decimals). We have docs for all of these settings.

This works great for 99% of the stores out there. There are a few exceptions that might require a couple snippets of code to display it exactly the way you want.

Duplicate Currency Symbols

Multiple Dollar Currencies

Which dollar are we using?

One specific example is with currencies that share symbols. For example the Australian, New Zealand,ย Singapore, and the US all user the same dollar symbol: $. This isn't too big of an issue if you cater to a specific country or region but some users won't understand the difference until they see the bill, or if using PayPal they see the converted total.

Add Currency Code Before Symbol

A potential solution is to show the currency code before the symbol. This way there isn't any confusion about the currency. Go ahead and download this mini plugin and install it into your site.


<?php
/**
* Plugin Name: WooCommerce Display Currency Code in Currency Symbol
* Plugin URI: https://gist.github.com/BFTrick/10681832
* Description: Add the currency code to the currency symbol in WooCommerce. Ex. USD $.
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
function patricks_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'USD':
$currency_symbol = 'USD $';
break;
case 'NZD':
$currency_symbol = 'NZD $';
break;
case 'AUD':
$currency_symbol = 'AUD $';
break;
}
return $currency_symbol;
}
add_filter('woocommerce_currency_symbol', 'patricks_currency_symbol', 30, 2);

You can do this with any currency. I just did it for US, Australian, & New Zealand dollars. You just need to enter your three letter currency code located in the get_woocommerce_currencies function.

australian-dollars

You can easily see this is Australian Dollars

55 thoughts on “Display Currency Code Infront of Symbol in WooCommerce

  1. Thanks for this it worked perfectly!

  2. Looks great – does this also work with order notification emails?

  3. How do I get this code into a format suitable for uploading to woocommerce as a plugin extension?

  4. I run an affiliate site using WooCommerce to control the look of the products displayed. So the cart of WooCommerce is not used at all.

    I now want to take on a New Zealand merchant but have no way to display their products with NZD either before or after the prices shown. Other merchants are in USD.

    Do you have a suggestion for me how I could handle this issue please?

    • Wow – what an interesting problem! I don’t think there are any solutions for this. WooCommerce is designed to use one currency. I’d have something custom built. There could be an extra setting on the product page where you select a currency which could replace the default currency.

      For something like this I’d use Codeable. They do awesome customizations.

      I hope that helps! ๐Ÿ™‚

  5. I’m setting up a site in Canada that charges USD for its products. Currently it just says $2000. I’d like it to say USD $2000. I think your plug-in will do that.

    Where do I put the PHP file for the code to take effect?

  6. Thanks a lot, you are awesome and I totally appreciate the work you’ve put into this plugin!

  7. Perfect. Thank you.

  8. It is not working properly with invoices and emails. Please help me with this.

  9. Here is my own version, inspired by your guide:

    function currency_indicator( $currency_symbol, $currency ) {
    global $post;

    // just on cart and checkout pages
    if ( is_product() )
    return $currency_symbol;
    else
    return $currency . ' ' . $currency_symbol;
    }
    add_filter( 'woocommerce_currency_symbol', 'currency_indicator', 30, 2 );

  10. Darryl Kraemer

    Thanks for this – exactly what we needed.

  11. Wonderful! Simple, quick, and helps when we know that the world doesn’t always revolve around the USD!!!

  12. Brilliant! Thank you!!

  13. hi, i cannot make it work on this.
    the plugins is activated but when echo get_woocommerce_currency_symbol() it still $ rather then USD$ in themes.
    any thing i did wrong? tq

  14. Hi,
    Thank you ๐Ÿ™‚
    I would like to ask about the reports. (Woocommerce>Reports>Orders)
    How can it show multiple currencies?
    Right now it sum up all orders and shows the total in USD .
    I only have CAD and USD in my shop at the moment.
    Thank you for your time and skillz
    Much appreciated ๐Ÿ™‚

  15. Hi Thanks this works perfectly, just a query if it is possible, i will like to show the price ( $ 65.65 USD).

  16. THANK YOU!! This works like a charm. ๐Ÿ™‚

  17. The currency code plugin is great ๐Ÿ™‚

    Thank you for sharing

  18. Thanks a lot. It really solved my problem.

  19. Is there any way to display the currency symbol only at the checkout page?

  20. hi, please i tried but did not work. Am using child theme of spacious theme. WordPress version 4.5.3 and woocommerce Version 2.6.2. Please patrick, help me. I will really be grateful.

  21. Thanks a lot, you are awesome and I totally appreciate the work youโ€™ve put into this plugin!

  22. Works exactly what i need… ๐Ÿ™‚
    Thanks

  23. why can’t i find this plugin?

  24. Hi Patric,
    Great your plug-in work fine thank you very much
    Ram

  25. New Zealand freelancer

    Thanks a lot! This simple but effective way of showing the currency with the price saved me from paying for the premium version of a plugin.

  26. Sorry for this rudimentary question – where should I add this function code in? Is it plugins -> editor -> woocommerce , or appearance editor? I am really a beginner.

  27. Amaazing! Thanks Patrick! I’m so happy now! I originally messaged the wordpress “happiness engineers” and they guided me to your plugin but since I have no experience in coding, I had no idea how to enter it and make it work. They told me they couldn’t help me or it might break my site and they weren’t sure if the code still worked since it’s been a few years. I installed the plugin called, “Code Snippets” and inputted the shorter version of your code, hit activate, voila, it worked! The longer coder with more currencies came up with a Syntex error so I just edited the shorter code to work with the currency codes I needed. That was super easy and didn’t break my site or cause me stress. Thanks, so much again!

  28. My website crashed after I put in the codes through code snippets in wordpress. Now I can’t even access my wordpress the whole website is down. What shuold I do?

  29. Created a folder, created a php file with the code, uploaded via FTP, doesn’t appear as a plugin. Is there any reason you can’t package this as a plugin that people can download and upload/activate?

  30. That worked perfectly fine. Thanks! ๐Ÿ™‚

  31. Hi there,

    Thanks for this, works great! Is it possible to have the code as a suffix instead of a prefix?

    Thanks,
    Luther

  32. That worked. Very thanks!

  33. Hello Patrick, thanks for your post, your code work perfectly in the page products, however I have a small problem, my Shop work with several currency and in the mini cart wiget, donยดt work the currency diferentiation, all products show the default currency of my shop. You have anything idea how solve my problem? thanks

  34. Fantastic I luve it when you find a plugin for such a specific purpose Well Done!!

  35. Patrick, You are literally the smartest guy on the planet, after searching the whole of the internet I could not find a solution for this and by chance i clicked on this post. I could’ve been lost for days. cheers my bro!

  36. I just added this to my site. Now my Canadian and Australian customers will not be confused when their card statement shows a different amount. Perfect solution – thanks!

  37. Thanks for sharing!

    Can we all at least take this lesson and agree that WC has consistently, over the years, lacked of common sense here, throughout the different plugins regardless which one it has been.

    Using currency symbols instead of currency ISO codes, let alone not giving people the option to choose, among other issues have the following consequences:

    – Errors for structured data
    – Errors for Google Merchant products
    – Customers can’t god damn differentiate between CAD $, USD $, NZ $, AUD $

    Does that make sense? No but does the imperial system even make sense?

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.