Skip to content

Instantly share code, notes, and snippets.

@woogists
Last active July 7, 2024 14:50
Show Gist options
  • Save woogists/72947b71e48a62f15f5548283d4ed00f to your computer and use it in GitHub Desktop.
Save woogists/72947b71e48a62f15f5548283d4ed00f to your computer and use it in GitHub Desktop.
Add a custom currency / symbol
/**
* 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;
}
@Khaoula300
Copy link

Thank you, it works :D

@Arsl143
Copy link

Arsl143 commented Jul 4, 2020

not work for me its like geo currency in need to change BD or BHD instead of د.ب

@neebzzzz
Copy link

how to add multiple currency not just one?

@tayebkhedrougui
Copy link

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

@BoxCurl
Copy link

BoxCurl commented Jun 1, 2022

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!

@Arsl143
Copy link

Arsl143 commented Jun 1, 2022

Please Use this snippet in your site
by using plugin
code snippet

WhatsApp Image 2022-06-01 at 3 45 39 PM

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;
}

@Arsl143
Copy link

Arsl143 commented Jun 1, 2022

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

WhatsApp Image 2022-06-01 at 3 45 39 PM

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;
}

@1101blueli
Copy link

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.

@Arsl143
Copy link

Arsl143 commented Feb 28, 2024

/**

  • 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;
}

@AndySharez
Copy link

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.

@Arsl143
Copy link

Arsl143 commented May 9, 2024

Hi Please use code snippet plugin to add this code.
https://wordpress.org/plugins/code-snippets/

@AndySharez
Copy link

AndySharez commented May 12, 2024

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.

uns curr

And for country I tried my own country,
but also created custom country (world) as well.

Problem still prevalent.

@AndySharez
Copy link

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.

uns curr

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?

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