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.

This topic contains 6 replies, has 2 voices.

Last updated by Bigul 3 weeks, 3 days ago.

Assisted by: Bigul.

Author Posts
October 31, 2024 at 2:01 pm #16351885

dennisv-7

Background of the issue:
I am trying to retrieve orders from the WooCommerce GET order API on my site hidden link. I am specifically looking for German orders but need the products in the default language, which is Dutch. The URL I am using is: hidden link 07:43:19&orderby=id&order=asc&limit=100&page=1&wpml_language=nl.

Symptoms:
When I include 'wpml_language=nl' in the API request, I miss the German orders. Removing it retrieves the German orders, but the products are in German instead of Dutch.

Questions:
How can I retrieve German orders with products in Dutch using the WooCommerce GET order API?
Is there a way to configure WPML to display products in the default language for German orders?

November 1, 2024 at 3:45 pm #16355569

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

You can use the wpml_object_id hook to get the ID of a post or taxonomy term in the current or specified language. Please refer to the following documentation for more details and let us know your feedback.

https://wpml.org/wpml-hook/wpml_object_id/

https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/

Sample code

//This will return the *German Product ID* for the *Dutch Product with ID 100*. If the German translation is missing for it, it will return NULL
echo apply_filters( 'wpml_object_id', 100, 'product', FALSE, 'de' );

--
Thanks!

Bigul

November 4, 2024 at 9:34 am #16359619

dennisv-7

Hello Bigul,

The external party uses a GET by URL and has no access on the site itself. For example:
Request: GET > hidden link 07:43:19&orderby=id&order=asc&limit=100&page=1&wpml_language=nl

I don't think the apply_filters will do much on their side. We think we have found a solution for this. We removed the 'wpml_language' parameter and added the 'lang' parameter with the value 'all'. We don't know why or how, but this way the products of the German orders are shown in Dutch (which is good) and now the product/order sync on their side is working normally again.

Do you think this is a solid solution or do you recommend something else?

November 5, 2024 at 8:56 am #16364852

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the details. I will check with our team and get back to you as soon as possible. Please wait.

--
Thanks!

Bigul

November 7, 2024 at 8:16 am #16375504

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Our team has shared the following feedback on this. Please check it and let us know your feedback.

It is indeed a bit surprising that it works this way. Please try adding &lang=nl as you like your current workaround. That sounds like a safer approach.

If it continues to work as is, it is an undocumented feature and it may stop working one day.

--
Thanks!

Bigul

November 7, 2024 at 9:43 am #16375899

dennisv-7

Hello Bigul,

As I stated, we've removed the 'wpml_lang' parameter and added the 'lang' parameter with the value 'all'. When we change the 'lang' parameter to 'nl', we only get the Dutch orders and no longer the German orders. If we changed the parameter to 'de', we only get the German orders.

The option 'all' is the only one to show all orders (Dutch and German orders) and displayed the orders in dutch. Which is exactly what we want. So your suggestion as a workaround will not be useful to us.

I really hope the 'all' option at the 'lang' parameter will stay this way...

November 7, 2024 at 1:26 pm #16377633

Bigul
Supporter

Languages: English (English )

Timezone: Europe/Vienna (GMT+01:00)

Hello,

Thank you for the updates. Our team has confirmed it will be safe. So please proceed with lang=all parameter. Please feel free to ping us if you need any further assistance.

--
Thanks!

Bigul

November 7, 2024 at 2:36 pm #16378228

dennisv-7

Hello Bigul,

Thank you for your help and the confirmation. We'll keep the 'all' option for now.