Hello,
I’m not super familiar with WooCommerce. You might be better off asking this in a forum specific to that plugin.
Thread Starter
adamjedgar
(@computersimulatorscom)
this is a php issue not woocommerce. Anyone who knows php should be able to help with this. In any case…I have my answer and it works brilliantly. Here it is below:
`add_filter( ‘woocommerce_currencies’, ‘add_my_currency’,20,1 );
function add_my_currency( $currencies ) {
$currencies[‘ABC’] = __( ‘Currency name’, ‘woocommerce’ );
return $currencies;
}
add_filter(‘woocommerce_currency_symbol’, ‘add_my_currency_symbol’, 20, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case ‘ABC’: $currency_symbol = ‘ m³ ‘;
break;
}
return $currency_symbol;
}`
-
This reply was modified 6 years, 11 months ago by
adamjedgar.
-
This reply was modified 6 years, 11 months ago by
adamjedgar.
Thread Starter
adamjedgar
(@computersimulatorscom)
there is a problem with the way the above is displaying…the line
case ‘ABC’: $currency_symbol = ‘ m³ ‘;
should read
case ‘ABC’: $currency_symbol = ‘ msup³ ‘;,
I cant stop this damn forum from automatically superscripting the “3” (that is only supposed to happen in code snippets. Anyway, you get the idea.
-
This reply was modified 6 years, 11 months ago by
adamjedgar.
Hi @computersimulatorscom,
I want to confirm this works for me as well.
In the spanish market we have different currencies that use the $ symbol, and even so the US dollar is present on the woocommerce list this can bring confusion to customers according to where they are in Latin America, so the need to have the $ symbol preceeded by ‘US’ is crucial.
Here is my code for it. I encounterd issues trying to name in spanish the custom currency because in spanish ‘Dollar’ is written ‘Dólar’ with an accent. I corrected this by simply naming it in english.
/**
* Custom USD currency and USD currency symbol
*/
add_filter( 'woocommerce_currencies', 'add_my_currency',20,1 );
function add_my_currency( $currencies ) {
$currencies['ABC'] = __( 'US Dollar', 'woocommerce' ); /*Do not include accents in the name, eg.: dólar. This will generate an error without explanation */
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 20, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'ABC': $currency_symbol = 'US$';
break;
}
return $currency_symbol;
}
Cheers