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:
The user would like to know how to programmatically detect the connected currency and get the exchange value?
Solution:
We have recently added a PHP function "wcml_get_woocommerce_currency" in WooCommerce Multilingual 4.6.7 to get default WC currency value from DB.

We can also use the following code:

global $woocommerce_wpml; 
$woocommerce_wpml->multi_currency->get_currencies();

This function should return an array with all the settings and you should find something there for your needs. This is not a proper way, though, to call our functions. If we need a specific hook, we should suggest it here https://wpml.org/suggest-a-new-feature-for-wpml/

This topic contains 4 replies, has 2 voices.

Last updated by jose-mariaG-11 1 month ago.

Assigned support staff: Jamal.

Author Posts
September 9, 2019 at 8:48 am #4534827

jose-mariaG-11

Hi,

I have made a custom javascript for woocommerce products, how can I detect the connected currency? How can I get the exchange value?

Thanks for your help.
Regards,
Jose

September 10, 2019 at 8:32 am #4543015

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello Jose,

Thank you for contacting WPML Support. I will be glad to help with this.

We have recently added a PHP function "wcml_get_woocommerce_currency" in WooCommerce Multilingual 4.6.7 to get default WC currency value from DB.
You can use this function to push the default currency into Javascript code.

For your second question, let me approach our 2nd Tier to get more details.
I'll get back to you as soon as possible.

Best regards,
Jamal
WPML Support

September 10, 2019 at 8:48 am #4543239

jose-mariaG-11

Thank you Jamal.
I hope you tell me something about the other question to start testing.

Regards,
Jose

September 10, 2019 at 12:03 pm #4545037

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello Jose,

Our developers have suggested using this piece of code to get all the information about currency including rates, available languages.

global $woocommerce_wpml; 
$woocommerce_wpml->multi_currency->get_currencies();

This function should return an array with all the settings and you should find something there for your needs. This is not a proper way, though, to call our functions. If you need a specific hook, you can suggest it here https://wpml.org/suggest-a-new-feature-for-wpml/

They added, that each product has all currencies available, the only restriction is by language.

If you still need more information, please provide a detailed explanation of what you try to achieve.

Best regards,
Jamal

September 13, 2019 at 7:26 am #4566011

jose-mariaG-11

My issue is resolved now. Thank you!