This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This thread is resolved. Here is a description of the problem and solution.

Problem:Want to change the Hong Kong dollar currency symbol from $ to HK$

Solution:Relevant Woocomerce Documentation:

->https://github.com/woocommerce/woocommerce/issues/1114

Custom Currency/Symbol : https://docs.woocommerce.com/document/add-a-custom-currency-symbol/

So far the best solution i have seen that does not require coding is the following add-on plugin recomended by Woocomerce , that allows you to edit the currency or symbol.

-> https://woocommerce.com/products/woocommerce-custom-currencies/

add_filter( 'woocommerce_currencies', 'add_my_currency' );
 
function add_my_currency( $currencies ) {
     $currencies['HKD'] = __( '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 'HKD': $currency_symbol = 'HK$'; break;
     }
     return $currency_symbol;
}

Relevant Documentation:

This topic contains 5 replies, has 3 voices.

Last updated by williamk-20 2 years, 3 months ago.

Assigned support staff: Bobby.

Author Posts
July 3, 2017 at 3:32 pm #1310889

YES!Design

Hello,
I have a website in French, American and Chinese.
I am trying to change the Hong Kong dollar from $ to HK$. I don't want my Chinese customer to think that they'll be charge in American dollar. In order to avoid confusion I prefer to have HK$ instead of $

URL of (my) website where problem appears: hidden link

Many thanks for your help.

Best

July 3, 2017 at 5:58 pm #1311030

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

Thank you for contacting WPML Support,

You can adjust your Currency Switcher in Woocomerce > WooCommerce Multilingual > Multi - Currency tab > Product page Currency Switcher and click on the "pencil " icon to edit.

There you can create a Custom template, and using the %code% parameter in the template will display USD and HKD instead of $ and $ . [view screenshot]

https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/

If you still wish to instead change the symbol to $HK from $ instead of using the above solution then you will need to do this with some custom code.

=> https://docs.woocommerce.com/document/change-a-currency-symbol/

July 4, 2017 at 7:11 am #1311301

YES!Design

Hello,
Thanks for your reply. I don't think option 1) is appropriate because I don't want a switcher I want to change the display of the currency symbol on a product page.

I prefer to use option 2) but in your example it is in AUD, what shall I put for HK$ ? I tried this but it doesn't work:

add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
     switch( $currency ) {
          case 'HK$': $currency_symbol = '$'; break;
     }
     return $currency_symbol;
}

On this page I want to have HK$ : hidden link

On this page I want to have just $ : hidden link

Many thanks for your help

July 4, 2017 at 6:21 pm #1311992

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

Due to option #2 being a custom solution, We are unable to provide support for code customizations under our Support Policy.

In addition, this is related to Woocomerce's code rather than WPML or WCML.

Relevant Woocomerce Documentation:

->hidden link

Custom Currency/Symbol : https://docs.woocommerce.com/document/add-a-custom-currency-symbol/

So far the best solution i have seen that does not require coding is the following add-on plugin recomended by Woocomerce , that allows you to edit the currency or symbol.

-> https://woocommerce.com/products/woocommerce-custom-currencies/

July 5, 2017 at 8:11 am #1312299

YES!Design

Ok great I've managed to do it by adding

add_filter( 'woocommerce_currencies', 'add_my_currency' );

function add_my_currency( $currencies ) {
     $currencies['HKD'] = __( '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 'HKD': $currency_symbol = 'HK$'; break;
     }
     return $currency_symbol;
}

Many thanks for your help

Best

August 14, 2019 at 1:48 pm #4395599

williamk-20

Hi, why don't WPML correct the currency symbol ? As all currency symbol showing $, which is totally wrong. Secondly, when I change the currency, the value change but the price symbol on the woocommerce still showing $ even though I used the custom code. The switcher is correct to the right symbol though.

add_filter( 'woocommerce_currencies', 'add_my_currency' );

function add_my_currency( $currencies ) {
$currencies['EUR'] = __( 'Euro', '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 'EUR': $currency_symbol = '€'; break;
}
return $currency_symbol;
}