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 thread is resolved. Here is a description of the problem and solution.

Problem:

I'm having trouble translating a variable product with a REST API call.

Solution:

Translations of products with variations over REST API are not working with WooCommerce Multilingual. I can see that our developers are planning to add support for this. But this is scheduled for a future version of WooCommerce Multilingual, and I cannot say when it will be available.

50% of people find this useful.

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by jiarongx 12 months ago.

Assigned support staff: Itamar.

Author Posts
October 12, 2018 at 7:26 am

jiarongx

I am trying to translate a product from english into Chinese and Japanese.
If we do it by WPML editor at the WP Admin console, it works perfectly.
But when we do it by calling the REST API the translated product missing the attributes and variations and SKU code information.
We are following the instruction here:https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/

We call the REST API by .Net.

We use SOAPUI to call as attachment is showing as well, but still fail.

October 14, 2018 at 8:42 am #2815118

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

You using outdated versions of WPML and its add-ons and also WooCommerce is not updated on your site to its latest version. Please update everything and see if it helps to solve this issue.

Another thing that I would like to ask you is to raise the WP Memory Limit. By looking at the debug info that you have attached I can see that your server WP Memory Limit is set to 40M.
Our recommendations are to have the following as minimal requirements:
- PHP 5.3 and above (this OK with your installation) with a WP Memory Limit of at least 128MB and more if possible.
- MySQL 5.6 and above (this OK with your installation).
Please follow this link for detailed documentation:
https://wpml.org/home/minimum-requirements/
Meeting those baseline requirements is most critical before starting to debug and sometimes solves issues like you experiencing.
Most important is to raise the WP Memory Limit.
Please try to raise it before you contact your hosting company.
You can try and do it from the wp-config.php file in your WordPress installation.
Insert this code in that file.

/** Memory Limit */
define('WP_MEMORY_LIMIT', '256M');
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Add it before this line:
/* That's all, stop editing! Happy blogging. */

Could you please perform those procedures and see if it help?

If all the above does not help, please give me some more information about the REST API process that you are doing.
You wrote: "We call the REST API by .Net. We use SOAPUI to call as attachment is showing as well, but still fail."

Could you please explain terms .Net and SOAPUI?
Could you attach here the API code that you are using?

Thanks,
Itamar.

October 14, 2018 at 11:19 am #2815373

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi again.

In addition to the about please also check the following.

We require that option "Enable Legacy API" in WooCommerce > Settings > Advanced > Legacy API will be enabled for things to work properly. Please see the attached screenshot.
Is it enabled on your site?

Regards,
Itamar.

October 14, 2018 at 4:41 pm #2815652

jiarongx

Hi Itamar,

Thanks for the reply.
For the "Legacy API support" config it has beed enabled before.So when we call the "Create Product" REST API shall we use the new API or use the Legacy API?

About the WPML version, we are using the version 4.3.6 which I think it is the latest version already as well as the add ons. The Woo Commerce version we are using is 3.4.5 as the latest version is 3.4.6.

Actually our requirement is to use REST API to create a translation of existing products whose description is in English. For example, now we get a product AAA, who get a product variation aaa. Now we want to add a Chinese translation to this Product AAA, let's call it AAA'. The steps we are taking is below:
1. Call "Create Product" to create a Chinese Product AAA' with the parameter lang and translation_of. The request body as below.

"{
""name"": ""Chinsese Test"",
""description"": ""Chinsese Test description"",
""short_description"": ""Chinsese Test short description"",
""type"":""variable"",
""regular_price"":""12307"",
""sale_price"":""12306"",
""attributes"": [ {
""id"": 18,
""position"":""0"",
""name"": ""Color"",
""visible"":""true"",
""variation"":""true"",
""options"":[ ""Red"",""Blue""]
}],
""categories"": [
{
""id"": 410,
""name"": ""Computer & GPS"",
""slug"": ""computer-gps""
}
],
""lang"":""zh-hans"",
""translation_of"": ""6910""
}"

2.Create a Chinese product variation belong to AAA' by below request.
"{
""name"": ""Chinsese Tes-Redt"",
""description"": ""Chinsese Test description-Red"",
""short_description"": ""Chinsese Test short description-Red"",
""regular_price"":""12307"",
""sale_price"":""12306"",
""attributes"": [ {
""id"": 18,
""name"": ""Color"",
""option"": ""Red""
}],
""categories"": [
{
""id"": 410,
""name"": ""Computer & GPS"",
""slug"": ""computer-gps""
}
],
""lang"":""zh-hans"",
""translation_of"": ""6911""
}"

After we do finish doing this, we can see both product AAA and AAA' in the Shop. The AAA would be show if the language was set to English while AAA' if the language switch to Chinese. But we are encountering an issue which is, if we put AAA into the Cart then switch to Chinese, the product in the Cart still show AAA (The english name), not AAA' (The Chinese name). But if we add the Chinese translation via WPML Editor Page, the product in the cart would be switched perfectly.

October 14, 2018 at 5:16 pm #2815665

jiarongx

Attach more information for your reference.
You can find this product here:
hidden link

October 15, 2018 at 6:19 pm #2818527

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hello and sorry for the late reply here.

About the "Legacy API support" question. I'm asking our second tier supporters about this issue and will get back to you here.

About the code in which you create the Chinese translation.
Is the created Chinese translation connected to the English product?
I'm trying to find out if it is only an issue when switching the language while on the cart or a problem when creating the translation with REST API.

About the WPML and add-ons versions.
The latest WPML version is 4.0.7, Strings Translation 2.8.7, Translation Management 2.6.7, WPML Media 2.3.7 so you are not using the latest versions at all.
Could you please update so we can proceed to investigate the issue that you have if the updating does not correct it?

Please also adjust the minimum requirement as I mentioned in my last reply.

Note: I cannot see the product that you have sent me as an example. I get a 404.

Regards,
Itamar.

October 16, 2018 at 9:48 am #2820410

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

Our second tier supporter told me that we should also be Compatible with the new REST API.

Regards,
Itamar.

October 16, 2018 at 3:10 pm #2821505

jiarongx

Hi Itamar,

As advised, we have updated the plugin versions, Please refer to the attach screen shot.
The product sent before was removed as we are doing testing.
I create it again.
You can find it via this url:hidden link

Thanks for your help.

October 17, 2018 at 3:39 am #2823099

jiarongx

And after we upgrade all the plugin to the latest version, it still can not work.

October 17, 2018 at 8:44 am #2823821

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi and thank you for updating WPML to its latest version.

Please confirm that the issue that you want us to debug in this ticket is the following issue as described by you. I ask for this confirmation because you have brought here a few issues and by now I'm not certain what do you want us to debug.

After we do finish doing this, we can see both product AAA and AAA' in the Shop. The AAA would be show if the language was set to English while AAA' if the language switch to Chinese. But we are encountering an issue which is, if we put AAA into the Cart then switch to Chinese, the product in the Cart still show AAA (The english name), not AAA' (The Chinese name). But if we add the Chinese translation via WPML Editor Page, the product in the cart would be switched perfectly.

To work with WPML and WooCommerce, we have the bridge plugin WooCommerce Multilingual.
To use WooCommerce Multilingual WPML's add-ons Strings Translation and Translation Management should also be updated to their latest version. Please understand that I cannot continue to debug the issue that you have until those add-ons are updated as well. It might be that the bug that we are trying to solve is already fixed with the latest versions. The Strings Translation and Translation Management add-ons are installed on your site but not updated. The reason that you cannot update those add-ons is that you have the Multilingual Blog package which does not contain those two plugins. To update those add-ons and be able to work with WooCommerce Multilingual you will need to upgrade your package to the Multilingual CMS package or the Multilingual Agency package. Please see our purchase page for more details on the following link.
https://wpml.org/purchase/

Regards,
Itamar.

October 17, 2018 at 11:02 am #2824262

jiarongx

Hi Itamar,

OK.We will consider it. But first of all, may I check with you that whether WPML plugin can support create variable product translation via REST API?
Our requirement is very simple, just to call the REST API to create a translation of a variable product and the result would be same as we create it via the WPML Editor. If this requirement can be fulfill and this issue is only the problem of thw way we call the REST API we are pleasure to purhcase the Multilingual CMS package (If this package support this requirement).

Thanks

October 18, 2018 at 12:45 pm #2827972

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi.

I've sent this question to our second tier supporter and I'll get back to you here once I have a reply from him.

Regards,
Itamar.

October 18, 2018 at 2:27 pm #2828326

jiarongx

Hi Itamar,

Thanks a lot. We have upgraded to Multilingual Agency package already.Please help to continue to debug this issue. Thank you very much.

Best Regards

October 18, 2018 at 11:11 pm #2829792

Itamar
Supporter

Languages: English (English ) Hebrew (עברית )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, and thank you for upgrading to the Multilingual Agency package.

I have a response from our third tier supporter.
I'm sorry, but currently, translations of products with variations over REST API are not working with WooCommerce Multilingual. I can see that our developers are planning to add support for this. But this is scheduled for a future version of WooCommerce Multilingual, and I cannot say when it will be available.

Regards,
Itamar.

October 22, 2018 at 7:16 am #2836939

jiarongx

Looking forward to the version support translations of products with variations over REST API.