Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created January 5, 2012 13:42
Show Gist options
  • Save mikejolley/1565309 to your computer and use it in GitHub Desktop.
Save mikejolley/1565309 to your computer and use it in GitHub Desktop.
WooCommerce - Filters to add custom currencies and symbols
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['ABC'] = __( 'Currency name', '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 'ABC': $currency_symbol = '$'; break;
}
return $currency_symbol;
}
@MatLeduc
Copy link

MatLeduc commented Aug 9, 2017

Hi Mike,

I was able to create a new custom currency "Canadian dollar (fr)".

I had to set the currency code of the new custom currency to "CAD-FR" because it was not working using CAD and because of that the Automatic Exchange Rates feature of WPML WooCommerce Mutilingual do not recognize it.
Error message: "Error reading the exchange rate for CAD-FR. Please try again. If the error persist, try selecting a different exchange rate service."

We want to make sure that the new custom currency will use the same Exchange Rate as the existing "Canadian dollar" currency.

Please provide a fix or code snippet to be able to use the same currency code (CAD) for both the existing “Canadian dollar” currency and the new custom “Canadian dollar (fr)” currency.

Thank you for your help!

Mathieu Leduc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment