Adding your own currency to WooCommerce

October 31st, 2012 by Sean Leave a reply »

woocommerce_logoI have been asked on a few occasions by people how to add a new currency to WooCommerce. It’s actually incredibly simple to do thanks to the excellent WooCommerce API. Simply add the following code to your theme functions.php file or to a plugin of your own for this to work. I used this same code in my recent Interswitch Payment Gateway integration for WooCommerce to add Nigerian Naira.

add_filter('woocommerce_currencies', 'sb_add_ngn_currency');
add_filter('woocommerce_currency_symbol', 'sb_add_ngn_currency_symbol', 10, 2);

function sb_add_ngn_currency($currencies) {
 $currencies['NGN'] = __( 'Nigerian Naira (NGN)', 'woocommerce' );
 return $currencies;
}
function sb_add_ngn_currency_symbol($currency_symbol, $currency) {
 switch( $currency ) {
 case 'NGN':
 $currency_symbol = '₦';
 break;
 }

 return $currency_symbol;
}

15 comments

  1. Dotun says:

    Hi,

    Great code.

    But whenever I add this code to the custom functions section of the functions.php, the website refuses to load.

    Am I doing something wrong?

  2. Dotun says:

    Hi,

    Never mind..I downloaded your plugin for interswitch and this corrected the currency challenge.

    Many thanks and great job.

  3. Ken says:

    Thanks a lot for helping …you really care about Nigeria because we have waited too long for an affordable payment gateway- a major problem to Nigerians’ small business owners who want an online presence.

  4. dave says:

    Can we get a step by step direction on adding currency?
    Thanks for the great job you’re doing.

    • Sean says:

      You just need to open up your theme functions.php file and put my code at the bottom before the closing ?>. It should work automatically then.

      thanks
      Sean

  5. dave says:

    I’m trying to add the Nigerian Naira to my site. Would this work for other ecommerce themes.

  6. Ken says:

    it works for me, thanks Sean!!!

  7. Ken says:

    What about this code bellow Sean?

    add_filter( ‘woocommerce_currencies’, ‘add_my_currency’ );

    function add_my_currency( $currencies ) {
    $currencies['NGN'] = __( ‘Naira’, ‘woocommerce’ );
    return $currencies;
    }

    add_filter(‘woocommerce_currency_symbol’, ‘add_my_currency_symbol’, 10, 2);

    function add_my_currency_symbol( $currency_symbol, $currency ) {
    switch( $currency ) {
    case ‘NGN’: $currency_symbol = ‘₦’; break;
    }
    return $currency_symbol;
    }

  8. Jide says:

    Quite helpful. Works for me. Thanks Sean

  9. Raghav says:

    Hi,

    How to show multiple currency in the product page for a single product. Like sell a product for $70 and €75

    Am using woocommerce shopping cart and woo commerce multilingual plugin.

    Can you assist me in the steps how to go about?

    Regards,
    Raghav.

    • Sean says:

      Hi Raghav,

      Adding several currencies at once would be cumbersome but there is a widget you can get which converts the currency for you on the fly I think. I have never used it myself but it seems to work in their examples. It’s $29 which isn’t too expensive for the functionality it offers.

      thanks
      Sean

  10. Ayisha says:

    Hi, Sean. I came across your website a few weeks ago and I was really thrilled cos it solved a big problem I was having at the time which was how to add the Naira currency to woocommerce. I dowloaded your plugin for interswitch and it worked. However, the naira sign does not appear on my price tags. I don’t know why. Only the currencies that originally came with woocommerce appears. Please I don’t know if you have an answer to this. Would really appreciate your helps. Thanks a lot.

    • Sean says:

      Hey Ayisha,

      Thanks for the feedback. I will look into it. However in the meantime just check the shop currency in the WooCommerce settings. Maybe you didn’t change it there?

      ta
      S

Leave a Reply