Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 5:00 – 13:00 5:00 – 13:00 5:00 – 13:00 5:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Argentina/Buenos_Aires (GMT-03:00)

This topic contains 3 replies, has 0 voices.

Last updated by Otto 6 days, 18 hours ago.

Assisted by: Otto.

Author Posts
February 4, 2025 at 2:51 pm #16667440

sagiS

Background of the issue:
I am experiencing an issue where the wcml_formatted_price function is not working when performing Add to Cart or Get Cart, or create order actions via GraphQL. We are currently using the following plugins: WooCommerce Multilingual & Multicurrency, WPGraphQL, WPML GraphQL. Despite having these plugins installed and activated, the price is not being converted properly within GraphQL mutations.

Symptoms:
The price is not being converted as expected during Add to Cart or Get Cart actions via GraphQL. The price remains unchanged instead of being converted to the selected currency.

Questions:
Could you please look into this issue and provide guidance on how we can ensure that the price conversion works correctly during GraphQL mutations?
Is there any specific documentation or guidance on ensuring price conversion during GraphQL mutations like Add to Cart and Get Cart?

February 5, 2025 at 3:17 pm #16671849

Otto
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hi,

To ensure the quickest and most accurate support, please provide your debug information so I can look at some of your configurations. We have an excellent article on how to locate it here: https://wpml.org/faq/provide-debug-information-faster-support/.

I'll need your help reproducing the problem, so I can take a better look and eventually escalate to a dev.

I've set up a fresh WP install with the required plugins. Can you please try to reproduce the issue there and then provide me with the steps to see it?

You can log in by following this link:
hidden link

Thanks!

Best Regards,
Otto

February 6, 2025 at 8:30 am #16673874

sagiS

Hi,

You don’t need debugger information for this, as it’s not an issue. I just need some clarification.

My site uses a currency converter powered by the WooCommerce Multilingual & Multicurrency plugin.
I am using the GraphQL plugin, where I have created a mutation.
The problem is that when I change the currency from the site, the mutation (which handles the cart) correctly reflects the converted currency in the API response.
📌 Screenshots:
🔗 hidden link
🔗 hidden link

However, if I don’t change the currency from the site, the API mutation does not convert the currency either.

How can I ensure that the currency conversion happens even when it is not changed from the site?

Looking forward to your response.

Best regards,
Pankaj sharma

February 6, 2025 at 3:22 pm #16676280

Otto
Supporter

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Thanks for the clarification.

I will need to check with our devs. Before doing so, allow me to be sure I am getting the issue properly.

- If you change the currency in the front end your graphQL mutations show the right price in the right currency.
- But, when using, for example:

apply_filters('wcml_formatted_price', $raw_price, $currency);

in your custom resolver mutation code it is not working. Am I right? It shows the $raw_price unchanged, no?

Please let me know if I get it right and feel free to add any extra information that may help.

Thanks!

Best Regards,
Otto