WooCommerce : How to Add Custom Currency and Symbol

WooCommerce is a popular wordpress eCommerce plugin. It was built with great flexibility. Today i would like to share how to add custom currency and currency symbol to your woocommerce shop.

For example, i will add Indonesia Rupiah (Rp).

First, you need to open “functions.php” file in your theme, and place below code:


add_filter( 'woocommerce_currencies', 'add_custom_currency' );

function add_custom_currency( $currencies ) {
$currencies["IDR"] = 'Indonesian Rupiah';
return $currencies;
}

add_filter('woocommerce_currency_symbol', 'add_custom_currency_symbol', 10, 2);

function add_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'IDR': $currency_symbol = 'Rp'; break;
}
return $currency_symbol;
}

Then you save the file, and you are ready to go.

For function add_custom_currency(), you can add any country currency code (refer to ISO 4217 Currency Codes) and update underlined line for below code:

$currencies[“IDR“] = ‘Indonesian Rupiah‘;

For function add_custom_currency_symbol(), you can update underlined line for below code:

case ‘IDR‘: $currency_symbol = ‘Rp‘; break;

If you go to the WooCommerce Settings panel and click General tab, you can select newly added currency.

WooCommerce Select Custom Currency - Indonesia Rupiah

WooCommerce Select Custom Currency - Indonesia Rupiah

After saved the settings, you can see updated view at live site.

Show Indonesia Rupiah currency for product price

Show Indonesia Rupiah currency for product price


11 Comments

  1. i have tried and tried and tried, i keep getting the following error :

    Parse error: syntax error, unexpected T_FUNCTION in /hsphere/local/home/a895899/secretlilies.com/wp-content/themes/jarida/functions.php on line 87

    i am using the jarida theme from them forest

  2. Hi
    My website is still under development. I wish to change the symbol of the currency Indian Rupees from ‘Rs’ to the new symbol. In the code above I understand that we must hardcode the value of the symbol. I found this video which explained how to insert the symbol using API but I am not sure how to use it on woocommerce. Could you take a look ?
    https://www.youtube.com/watch?v=JYxhRlVNZbU

  3. Hi Terry,
    I tried to insert the custom currency and symbol but received this message: Parse error: syntax error, unexpected ‘3’ (T_LNUMBER) in /home1/mikemily/public_html/wp-content/themes/storefront/functions.php on line 20
    How do I solve this problem? I can’t login to my website.

Leave a Comment.