Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

How to add a custom currency and symbol in WooCommerce

May 2, 2017

3 Min Read
Reading Time: 3 minutes

WooCommerce is a popular WordPress eCommerce plugin that offers great options for customization of the store. In this tutorial,  I will highlight how to add custom currency symbol in a WooCommerce store.

By default, WooCommerce comes with many currency options. However, if you wish to add another currency (and its symbol), the process is very straightforward.

custom currency

For the purpose of this tutorial, I will add a dummy currency with the name CLOUDWAYS CURRENCY and will use the symbol, ‘CW$’ for it.

Open the functions.php, located in the theme folder.

Now, add the following lines of code at the end of the file and save the file.

add_filter( 'woocommerce_currencies', 'add_cw_currency' );
function add_cw_currency( $cw_currency ) {
     $cw_currency['CLOUDWAYS'] = __( 'CLOUDWAYS CURRECY', 'woocommerce' );
     return $cw_currency;
}
add_filter('woocommerce_currency_symbol', 'add_cw_currency_symbol', 10, 2);
function add_cw_currency_symbol( $custom_currency_symbol, $custom_currency ) {
     switch( $custom_currency ) {
         case 'CLOUDWAYS': $custom_currency_symbol = 'CW$'; break;
     }
     return $custom_currency_symbol;
}

Now, go to backend of the WordPress website, navigate to the WooCommerce tab and then Settings.

currency options

Click the Currency drop down under Currency Options, you will see the newly added custom currency at the end of the dropdown.

country

Select the newly added currency from here and save the settings.

Code Explanation

The following function adds a custom currency:

add_filter( 'woocommerce_currencies', 'add_cw_currency' );
function add_cw_currency( $cw_currency ) {
     $cw_currency['CLOUDWAYS'] = __( 'CLOUDWAYS CURRECY', 'woocommerce' );
     return $cw_currency;
}

Since I created a custom currency, CLOUDWAYS CURRENCY that appears on the backend:

currency position

add_filter('woocommerce_currency_symbol', 'add_cw_currency_symbol', 10, 2);
function add_cw_currency_symbol( $custom_currency_symbol, $custom_currency ) {
     switch( $custom_currency ) {
         case 'CLOUDWAYS': $custom_currency_symbol = 'CW$'; break;
     }
     return $custom_currency_symbol;
}

The above function adds the currency symbol. I have use CW$ as the currency symbol.

product

Go to the front end, and refresh the page. You will see the newly added custom currency being displayed at product pages.

product default sorting

Conclusion:

In this tutorial, I discussed how to add custom currency and symbol in WooCommerce. The code is pretty simple and involves adding a custom filter to the functions.php. If you need further help with the topic, Do leave a comment below and I will get back to you.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Your WooCommerce Store Needs A Reliable Host

With no compromise on Performance, Security & Support.

Owais Alam

is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform and a seasoned PHP developer. He loves to develop all sorts of websites on WordPress and is in love with WooCommerce in particular. You can email him at owais.alam@cloudways.com

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!