Skip Navigation

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

Problem:
The client needed to display the currency code as "AED" in English and "د.إ" in Arabic on their WooCommerce website.
Solution:
We recommended using the

wpml_current_language

filter hook to determine the current language and then display the appropriate currency code. Here is a step-by-step guide:
1. Add a filter to the

woocommerce_currency_symbol

.
2. Use the

wpml_current_language

filter to get the current language.
3. Depending on the language, set the currency symbol to "AED" for English or "د.إ" for Arabic.
Here is the example code:

add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
 
function change_existing_currency_symbol( $currency_symbol, $currency ) {
    $my_current_lang = apply_filters( 'wpml_current_language', NULL );
    switch( $currency ) {
        case 'AED':         
        if( $my_current_lang == 'en' ) {        
            $currency_symbol = 'AED'; 
        } else{
            $currency_symbol = 'د.إ'; 
        } 
        break;          
    }
    return $currency_symbol;
}

We also informed the client that custom code assistance is beyond the scope of WPML support and suggested contacting one of our certified partners if they need further help with the implementation.

Please note that this solution might be irrelevant due to being outdated or not applicable to your case. If this solution does not solve your issue, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket.

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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Long Nguyen 9 months, 2 weeks ago.

Assisted by: Long Nguyen.

Author Posts
February 20, 2024 at 2:29 am #15320405

itsFarouk

Hi,

2- in my website the currency are AED, by default in woocommerce it's "د.إ" so I had to put a function in function.php to change it to AED, but in Arabic it should be "د.إ" and I could translate the AED.

Thank you

February 20, 2024 at 2:38 am #15320408

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

I understand that you want to display the currency code "AED" in English, and "د.إ" in Arabic. I suggest you use the filter hook "wpml_current_language" to get the current language and display the currency code accordingly.
Refer documentation https://wpml.org/faq/how-to-get-current-language-with-wpml/

For example:

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

function change_existing_currency_symbol( $currency_symbol, $currency ) {
    $my_current_lang = apply_filters( 'wpml_current_language', NULL );
    switch( $currency ) {
        case 'AED':         
        if( $my_current_lang == 'en' ) {        
            $currency_symbol = 'AED'; 
        } else{
            $currency_symbol = 'د.إ'; 
        } 
        break;          
    }
    return $currency_symbol;
}

Note: I would like to inform you that helping you with custom code, is out of the scope of WPML. If you are not able to accomplish this, I would recommend you contact one of our certified partners who will be more than happy to help you with this. In this link, you will find a list of our certified partners: https://wpml.org/contractors/

Look forward to your reply.
Thanks

February 20, 2024 at 9:39 am #15321374

itsFarouk

I have the proper knowledge of development, thank you and I will apply this solution.