Change WooCommerce dollar currency symbol — add country code to the $ symbol

By default, there are 23 (maybe more), countries using the same default $ currency symbol in WooCommerce — the problem, however, is that the prices on the user-facing end will only display this symbol and NOT the representing country. Site administrators can easily see the representing countries when setting the currency, from wp-admin/admin.php?page=wc-settings page, but this can be super confusing to your users since they don’t see the same as you — is your shop prices displayed in US$, CA$, NZ$, or maybe SG$, JM$, or NA$? You get the point .. visitors have no idea!

To give you a better idea (using Australian dollar as my currency):

Here’s what the user will see in the shop (everywhere the price is displayed):

See how confusing it can be ..

The following code will prefix the representing country code to each country that uses the $ symbol so that the same thing you see in the back can be seen on the user-facing side:

function rs_custom_currency_symbols( $currency_symbol, $currency ) {
    switch( $currency ) {
        case 'USD':
            $currency_symbol = 'US $';
            break;
        case 'AUD':
            $currency_symbol = 'AU $';
            break;
        case 'BBD':
            $currency_symbol = 'BB $';
            break;
        case 'BMD':
            $currency_symbol = 'BM $';
            break;
        case 'BND':
            $currency_symbol = 'BN $';
            break;
        case 'BSD':
            $currency_symbol = 'BS $';
            break;
        case 'BZD':
            $currency_symbol = 'BZ $';
            break;
        case 'CAD':
            $currency_symbol = 'CA $';
            break;
        case 'FJD':
            $currency_symbol = 'FJ $';
            break;
        case 'GYD':
            $currency_symbol = 'GY $';
            break;
        case 'HKD':
            $currency_symbol = 'HK $';
            break;
        case 'JMD':
            $currency_symbol = 'JM $';
            break;
        case 'KYD':
            $currency_symbol = 'KY $';
            break;
        case 'LRD':
            $currency_symbol = 'LR $';
            break;
        case 'NAD':
            $currency_symbol = 'NA $';
            break;
        case 'NZD':
            $currency_symbol = 'NZ $';
            break;
        case 'SBD':
            $currency_symbol = 'SB $';
            break;
        case 'SGD':
            $currency_symbol = 'SG $';
            break;
        case 'SRD':
            $currency_symbol = 'SR $';
            break;
        case 'TTD':
            $currency_symbol = 'TT $';
            break;
        case 'TWD':
            $currency_symbol = 'NT $';
            break;
        case 'XCD':
            $currency_symbol = 'EC $';
            break;
    }
    return $currency_symbol;
}
add_filter('woocommerce_currency_symbol', 'rs_custom_currency_symbols', 30, 2);

Results, after adding the code (still using Australian dollar as my currency):

Cheers!


Was this helpful? Please buy me a coffee






This code should be added to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update.

Share your thoughts

Your email address will not be published. Required fields are marked *