Background of the issue:
I am trying to retrieve orders via the WooCommerce API endpoint /wp-json/wc/v3/orders?customer=1&lang=ar while using WooCommerce HPOS with WPML. The goal is to receive all orders translated into the specified language.
Symptoms:
When the lang parameter is passed, only the orders created in the specified language are returned, instead of all orders being translated.
Questions:
Why are only orders created in the specified language being returned?
How can I retrieve all orders translated into the specified language?
parameter filters orders based on their original creation language. Therefore,
?lang=ar
returns only orders placed in Arabic.
Retrieving All Orders: To get all orders, remove the
lang
parameter from your API request. This will return all orders in their original languages.
Translating Orders: To display all orders in Arabic, consider implementing a custom solution that translates order data into the desired language. This may involve using WPML's String Translation features or developing a custom function to handle the translation, but custom programming work is beyond the scope of our support.
Translating Orders is not a default workflow in WPML. Can you elaborate a bit more on what's your goal when doing this? Maybe we can think of an alternative flow or a workaround.
I will clarify the case when the option of woocommerce HPOS wasn't enabled... and we chose from wpml->settings->post type translations-> Orders (shop_order) to "Not Translatable" Everything was working fine we can see the same orders when passing lang param en or ar displayed with its translation entered in string translation in arabic case ...because the orders were saved as a custom post type which allows setting the translation preference for Orders (shop_order) to "Not Translatable" by this way when fetching the orders all orders are returned.
Now when HPOS is enabled there is no option to select "Not Translatable" because the orders are saved in a custom table related to the woocommerce so when the orders list API is called it always returns orders placed for the sent language value.
If you don't send the language parameter don't you get all the orders? What is the issue in this case?
You may also take a look at this option:
❌ Try it only in a dev or staging environment please ❌
Check "Enable compatibility mode (synchronizes orders to the posts table)" in WooCommerce settings (WooCommerce > Settings > Advanced > Features)
This option ensures that WooCommerce orders remain synchronized with the WordPress posts table (wp_posts), even when HPOS (High-Performance Order Storage) is enabled. When enabled, orders are duplicated in wp_posts with post_type = shop_order.
Best Regards,
Otto
The topic ‘[Closed] WooCommerce HPOS List Orders API Case’ is closed to new replies.