-
-
Save woogists/72947b71e48a62f15f5548283d4ed00f to your computer and use it in GitHub Desktop.
/** | |
* Custom currency and currency symbol | |
*/ | |
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 there, hope you´re doing great!
Well...I´ve recently updated to woo 6.5.1, the code above dosn´t work anymore.
Is it posible that some class has been modified?
Best regards!
Please Use this snippet in your site
by using plugin
code snippet
add_filter('woocommerce_currency_symbol', 'my_custom_currency_symbol', 10, 2) ;
function my_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'BHD': $currency_symbol = 'BHD';
break;
}
return $currency_symbol;
}
not work for me its like geo currency in need to change BD or BHD instead of د.ب
Did you solve the problem? i have the same issue. i want to replace د.ج with DZD
Please Use this snippet in your site change to your currency code BHD
by using plugin
code snippet
add_filter('woocommerce_currency_symbol', 'my_custom_currency_symbol', 10, 2) ;
function my_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'BHD': $currency_symbol = 'BHD';
break;
}
return $currency_symbol;
}
Took me a while to make it works. For those who may want to know.
After you added the snippet. You have to enable the custom currency from Woocommerce Settings - > Currency options.
/**
- Change a currency symbol BHD
*/
add_filter('woocommerce_currency_symbol', 'bhd_custom_currency_symbol', 10, 2) ;
function bhd_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'BHD': $currency_symbol = 'BHD';
break;
}
return $currency_symbol;
}
/**
- Change a currency symbol AED
*/
add_filter('woocommerce_currency_symbol', 'aed_custom_currency_symbol', 10, 2);
function aed_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'AED': $currency_symbol = 'AED'; break;
}
return $currency_symbol;
}
/**
- Change a currency symbol SAR
*/
add_filter('woocommerce_currency_symbol', 'sar_custom_currency_symbol', 10, 2);
function sar_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'SAR': $currency_symbol = 'SAR'; break;
}
return $currency_symbol;
}
/**
- Change a currency symbol OMR
*/
add_filter('woocommerce_currency_symbol', 'omr_custom_currency_symbol', 10, 2);
function omr_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'OMR': $currency_symbol = 'OMR'; break;
}
return $currency_symbol;
}
/**
- Change a currency symbol KWD
*/
add_filter('woocommerce_currency_symbol', 'kwd_custom_currency_symbol', 10, 2);
function kwd_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'KWD': $currency_symbol = 'KWD'; break;
}
return $currency_symbol;
}
/**
- Change a currency symbol QAR
*/
add_filter('woocommerce_currency_symbol', 'qar_custom_currency_symbol', 10, 2);
function qar_custom_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'QAR': $currency_symbol = 'QAR'; break;
}
return $currency_symbol;
}
Hi,
added this to my functions.php,
however, now I get the alert:
Unsupported currency: The selected currency is not available for the country set in your WooPayments account.
Is there a way to resolve this?
Thanks.
Hi Please use code snippet plugin to add this code.
https://wordpress.org/plugins/code-snippets/
Hi Please use code snippet plugin to add this code. https://wordpress.org/plugins/code-snippets/
Hello, I have done so; selected 'Run everywhere'.
But the problem is still the same; same orange alert at top of dashboard page.
And for country I tried my own country,
but also created custom country (world) as well.
Problem still prevalent.
Hi Please use code snippet plugin to add this code. https://wordpress.org/plugins/code-snippets/
Hello, I have done so; selected 'Run everywhere'.
But the problem is still the same; same orange alert at top of dashboard page.
And for country I tried my own country, but also created custom country (world) as well.
Problem still prevalent.
Hey guys, does anyone have a solution for "Unsupported Currency" in woocommerce?!
I mean, it can't be there is no solution for it, can it?
Did you solve the problem? i have the same issue. i want to replace د.ج with DZD