×

 

Home Contact Us Payments SC Commerce SC Commerce Docs SC Commerce Snippets

Simply Computing

We make websites. Simple.

Add country prefix before $ in prices

The $ currency symbol is used by many countries. To avoid confusion for customers, this code can be used to add the country prefix to the price.

		/**
 * Add country prefix before dollar in prices
 */

add_filter('woocommerce_currency_symbol', 'cc_add_currency_prefix', 30, 2);

function cc_add_currency_prefix($currency_symbol, $currency) {

  switch($currency) {
    case 'USD':
      $currency_symbol = 'US$';
      break;
    case 'CAD':
      $currency_symbol = 'CA$';
      break;
    case 'NZD':
      $currency_symbol = 'NZ$';
      break;
    case 'AUD':
      $currency_symbol = 'AU$';
      break;
  }

  return $currency_symbol;

}
	
   View Raw Code ID: 9905