This thread is resolved. Here is a description of the problem and solution.
Problem: The client is trying to retrieve German orders from the WooCommerce GET order API but wants the products to be displayed in the default language, Dutch. Including 'wpml_language=nl' in the API request causes German orders to be missed, and removing it results in products being displayed in German. Solution: We recommend removing the 'wpml_language' parameter from the API request and instead adding the 'lang' parameter with the value 'all'. This adjustment has shown to display all orders (both Dutch and German) with the products in Dutch, which is the desired outcome. If this solution continues to work, it should be noted that it might be an undocumented feature and could potentially stop working in the future.
Please note that this solution might become irrelevant due to updates or may not apply to your specific case. 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 the issue persists, 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.
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?
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.
//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' );
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?
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.
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...
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.