I'm using the recently released WooCommerce plugin for my e-commerce site. In WooCommerce settings, the currency of my country is not listed. So I have to add it manually by coding in woocommerce.php and admin-settings.php file.

The issue arises when there is an update. As soon as I update the plugin, the file is replaced with the new one in which my manually added code gets deleted and again, the currency of my country is not listed.

How do I ensure that the updates do not replace the currency listings which I manually coded?


You have two options:

Contact Woo

You can ensure your changes will be permanent by contacting WooThemes (the authors of the plugin) directly and asking them to add your country's currency to the list.

Use a filter

Alternatively, remember that everything is filtered. Woo is using the woocommerce_currency_symbol filter in woocommerce.php. To add currencies to that list, you'd use:

function add_my_currency_symbol( $currency_symbol, $currency ) {
    if($currency == "USD") {
        $currency_symbol = '$';
    return $currency_symbol;
add_filter( 'woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2 );

Whenever Woo calls their function, they pass the currency symbol through a filter before returning it. You're just hooking on to that filter, checking to see if the currency matches your custom value, and returning a custom symbol if so. I used US dollars here as an example, but substitute whatever it is you need.

To add your currency to the settings page, you'll hook into the woocommerce_currencies filter:

function add_my_currency( $currencies ) {
    $currencies["USD"] = 'US Dollars ($)';

    return $currencies;
add_filter( 'woocommerce_currencies', 'add_my_currency', 10, 1 );

Woo is adding an array of currencies to their options panel. All this does is look at the array, add your custom currency, then return it so the function can operate as normal.

Where to put this code

To use these filters, you'll have to write a second plugin. Give it a unique name and activate it as you would any other plugin. When you update WooCommerce, so long as they don't change their filter names, you shouldn't lose any customizations.

  • That did the trick. Thank you so much. Much appreciated. – input Nov 3 '11 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.