Skip Navigation

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

Problem:
The client has an online store serving the GCC countries and is using WPML and WCML plugins to translate the store and provide products in local currencies. The issue is that WooCommerce only shows currency symbols in Arabic format, which is not professional, and the client wants to display custom currency symbols for both English and Arabic versions of the store.

Solution:
We recommended registering the currency symbol string to a text domain using the following code and replacing "your-domain-name-here" with a descriptive domain name:

add_filter("woocommerce_currency_symbol", "change_existing_currency_symbol", 10, 2);
 
function change_existing_currency_symbol($currency_symbol, $currency)
{
    switch ($currency) {
        case "AED":
            if (ICL_LANGUAGE_CODE == "en") {
                $currency_symbol = __("AED", "your-domain-name-here");
            } else {
                $currency_symbol = __("درهم إماراتي", "your-domain-name-here");
            }
            break;
    }
    return $currency_symbol;
}

After adding the code to the theme's functions.php file, the client should scan the theme for strings and translate them. For more information, please refer to our documentation on enabling text translation for themes not compatible with WPML.

If this solution does not apply or is outdated, or if you encounter further issues, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If needed, please open a new support ticket in our support forum.

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 topic contains 1 reply, has 2 voices.

Last updated by Mateus Getulio 7 months, 3 weeks ago.

Assisted by: Mateus Getulio.

Author Posts
March 23, 2024 at 10:56 am #15443025

tareqA-6

I have built an online store starting from an English template and then used WPML plugin to translate it into Arabic. Initially, this website is supposed to serve the 6 GCC countries (Saudi Arabia, United Arab Emirates, Qatar, Bahrain, Kuwait and Bahrain).

I am also using WCML plugin to geolocate my customers in these countries and provide them with my products in their currency, both in the English and Arabic versions of the online store.

My problem is that WooCmmerce only shows currency symbols for these countries in Arabic format and even that format is not acceptable and not professional at all.

I found codes online that helped me force a custom currency symbol for the English version of my website/online store. However, since I am using WPML to translate the website to Arabic, those codes need to reflect on the Arabic version of the website.

This is an example of a code I found in one of your articles under the support section of your website.

add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);

function change_existing_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'AED':
if(ICL_LANGUAGE_CODE=='en'){
$currency_symbol = 'AED';
}else{
$currency_symbol = 'درهم إماراتي';
}
break;
}
return $currency_symbol;
}

The above code fixes my issues for the United Arab Emirates Dirham symbol (AED) for the English version of the website but it does nothing for the Arabic version in the sense that د.إ symbol in Arabic has not changed to درهم إماراتي when the language of the website is Arabic.

I tried to look for the symbol AED in the English version of the website using String Translation so that I translate it to درهم إماراتي so that whenever my customer switches the language from English to Arabic, AED will switch to درهم إماراتي but I couldn’t find the AED by all the means I learned from your documentation. I guess the reason is that this symbol is impeded by a CSS code.

I found a document on your website explaining how to translate codes using gettext feature in your website. Still, that article was extremely lengthy and very difficult for me to understand.

Please note that the above problem was an example of only using the United Arab Emirates currency symbol د.إ and AED. I need my website to translate and show currency symbols for all the other GCC countries.

I need help regarding this issue and I hope you will be able to provide that help with my full gratitude in advance.

March 24, 2024 at 9:54 pm #15444425

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Can you try to register the string to a text domain with a code similar to this?(please change the domain name to something descriptive)

add_filter("woocommerce_currency_symbol", "change_existing_currency_symbol", 10, 2);

function change_existing_currency_symbol($currency_symbol, $currency)
{
    switch ($currency) {
        case "AED":
            if (ICL_LANGUAGE_CODE == "en") {
                $currency_symbol = __("AED", "your-domain-name-here");
            } else {
                $currency_symbol = __("درهم إماراتي", "your-domain-name-here");
            }
            break;
    }
    return $currency_symbol;
}

Then, assuming you added it to your theme's functions.php file, you'll be able to scan your theme for strings and translate them.

For further reference, please check this: https://wpml.org/documentation/support/enabling-text-translation-for-themes-not-compatible-with-wpml/

Please give it a try and let us know the results.