-
-
Save mikejolley/1565309 to your computer and use it in GitHub Desktop.
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; | |
} |
hi
please add Iran's currency and cities to core
function add_my_currency( $currencies ) {
$currencies['IRR'] = __( 'ریال', 'woocommerce' );
$currencies['IRT'] = __( 'تومان', 'woocommerce' );
return $currencies;
}
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'IRR': $currency_symbol = 'ریال'; break;
case 'IRT': $currency_symbol = 'تومان'; break;
}
return $currency_symbol;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
Mike,
Is this code still working with the newest versions of Wordpress (4.8.1) and Woocommerce (3.1.1)? I added it to the functions.php of our child theme and it's not working. Tried to find the new custom currency in "Woocommerce/Settings/General/Currency" and the new currency is not showing up.
My goal is to add a custom currency for the French Canadian version of our site because the Currency Position, Thousand Separator and Decimal Separator are different from the English Canadian version.
English Canadian price format should look like this: ($9,999.99)
French Canadian price format should look like this: (9 999,99 $)
We are using WPML Woocommerce Multilingual to have multi-currencies on our site and set different Currency Position, Thousand Separator and Decimal Separator for each currency.
We can use the existing "Canadian dollar" currency to show the English Canadian price format but we are not able to use the same currency (Canadian dollar) twice on the Woocommerce Multilingual Multi-currency section.
Note: We also want to make sure that the new custom currency (French Canadian) will use the same Exchange Rate as the existing "Canadian dollar" currency.
Thank you for your help!
Mathieu Leduc
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
When I add a new currency, paypal dont recognize it...how to solve that problem?