Skip to content Skip to sidebar

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 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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 10 months, 3 weeks ago.

Assisted by: Otto.

Author Posts
February 11, 2025 at 2:25 pm #16692142

saadI-4

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?

February 11, 2025 at 5:10 pm #16693050

Otto
WPML Supporter since 09/2015

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

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

Hello,

  • Understanding the Behavior: The
    lang

    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.

If you need custom programming work I would suggest you consider contacting one of our certified partners from this link: http://wpml.org/documentation/support/wpml-contractors/
You will get the custom assistance you need to get on with your project.
Before doing so please have a look also here:
http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/"

Best Regards,
Otto

February 12, 2025 at 8:44 am #16694652

saadI-4

Hello Otto,

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.

February 12, 2025 at 1:04 pm #16696474

Otto
WPML Supporter since 09/2015

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

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

Thank you for the explanation.

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.