Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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.

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