WooCommerce transforms your WordPress blog to an online store with and I recently had to use it on a client’s website. Although it’s free and works great, there are lots of features you need to manually add through functions.php or find a plugin to do the job. One of such is the limited currencies available from the dashboard. The online store is based in Nigeria and it only makes sense to ensure the currency is in Naira.
In my search to find a solution, I stumbled across this code by Sean Barton. By editing this code you can add just about any currency to your store:
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;
}
It’s easy to edit this code and there are just a few things to change to add your own custom currency. For example, to add the Vietnamese Dong, you should have this:
add_filter('woocommerce_currency_symbol', 'sb_add_vnd_currency_symbol', 10, 2);
function sb_add_ngn_currency($currencies) {
$currencies['VND'] = __( 'Vietnames Dong (VND)', 'woocommerce' );
return $currencies;
}
function sb_add_vnd_currency_symbol($currency_symbol, $currency) {
switch( $currency ) {
case 'VND':
$currency_symbol = '₫';
break;
}
return $currency_symbol;
}
For your currency code and exact symbol to use, you may check this page. You can change this to work the way you want and add any currency.