Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is unable to retrieve the translated version of a product using the WordPress REST API. They are trying to access the English version of a product but keep receiving the Danish (original language) version instead.
Solution:
1. To access a specific translated product, use the translated product's ID in the URL without the need to add the

?lang=en

parameter. For example:

https://jumbo.as/wp-json/wc/v3/products/TRANSLATED_PRODUCT_ID

2. To get a list of products in a specific language, include the

lang

parameter in the URL. For example, to get products in English:

https://jumbo.as/wp-json/wc/v3/products/?lang=en

If this solution doesn't look relevant, please open a new support ticket and we will be happy to assist you further.

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 1 reply, has 2 voices.

Last updated by Long Nguyen 1 year, 6 months ago.

Assisted by: Long Nguyen.

Author Posts
November 23, 2023 at 9:06 am #14905159

ditteK

Every time I try to follow the documentation I could find, it only returns the original version.

To use an example, when I use hidden link it just returns the danish(original) results to me. It is very evident by the description, which is viewable on this link:
English: hidden link
Danish: hidden link

I have tried authenticating through both wordpress and woocommerce Rest API, both work for the danish(original), and I do have the woocommerce multilingual & currency addon installed. I would rather it just be able to go through the original wordpress REST API since it is easier to address the ACFs I have.

!Disclaimer I am not the original maker of the site, I have inherited from the previous person in my position.

November 24, 2023 at 9:55 am #14915107

Long Nguyen
WPML Supporter since 02/2022

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi Ditte,

Thank you for contacting WPML support, I'd be happy to help you with this issue.

If you add a specific product ID to the URL, it will return only the language of that product and no need to add the "lang" parameter then. You can add the translation product ID to the URL and let me know how it goes:
hidden link

If you want to get a list of products in English, you can add the "lang" parameter to the URL. For example: hidden link
and check the screenshot attached.

Look forward to your reply.
Thanks

http:::localhost:8888:wpml:wp-json:wc:v3:products:.png
November 27, 2023 at 7:57 am #14927117

ditteK

Hello Long Nguyen
Thanks, I has not considered that the ID would be different, I was following this https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/
And thought it would be enough to use the same product id but with the lang variant. I found out through your comment, that I can indeed pull it through either the wocommerce or the REST API that is built into WordPress, which is the best possible outcome. Thanks for your assistance