Skip Navigation

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.

Our next available supporter will start replying to tickets in about 3.13 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Bruno Kos 1 year, 2 months ago.

Assigned support staff: Bruno Kos.

Author Posts
May 3, 2019 at 6:06 pm

yoshiP

I am trying to:
I create a product (or update that product) via a first post. I hereby retrieve the ID of that product within WooCommerce, I use this ID to create a language update array like this:

$productData = [
			'title' => 'Andere naam',
			'name' 	=> 'Andere naam',
			'type' 	=> 'simple',
			'description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.',
			'short_description' => 'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.',
			'translation_of' => 61515,
			'lang' => 'en'
		];

If I use a PUT, I get "Using "translation_of" requires providing a "lang" parameter" error

I checked the code and I saw that execution is refused if it does not arrive via a POST:

"if (isset ($ data ['long']) && 'POST' === $ request-> get_method ()) {"

so I ran the same request through POST, after which I got no errors, but then WPML adjusts the text for all languages and not the one I specify

May 4, 2019 at 9:28 am #3739627

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

I create a product (or update that product) via a first post.

Can you give me more information on what this means and how this works, perhaps step-by-step or screenshots?

If I use a PUT, I get "Using "translation_of" requires providing a "lang" parameter" error

Can you give me more information about this as well - how do I test this? I would like to send this to our 2nd tier for more information, but would need more information on how this works.

Regards,
Bruno Kos

May 7, 2019 at 6:35 am #3754413

yoshiP

Just try to do a CURL call to the API with PUT and give it following parameters: "translation_of": {{id}}, "lang": "en".

You will see the issue.

May 7, 2019 at 9:05 am #3755673

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

I apologize, but I will need more info than that. Would you be able to replicate this on a clean Sandbox installation if I provide one, so that we can exclude that the issue is not related to your specific installation and setup?

Regards,
Bruno Kos

May 7, 2019 at 11:09 am #3756841

yoshiP

Yes, but we need WooCommerce.

But we are sure this is a bug in the api. As state, this part of the code:
if (isset ($ data ['long']) && 'POST' === $ request-> get_method ()) {

Checks for a POST, a PUT is not possible.

May 7, 2019 at 12:10 pm
May 9, 2019 at 9:46 pm #3779405

yoshiP

So we start with a product with french as language (WhatsApp Image 2019-05-08 at 18.09.04.jpeg)
We do a POST request with a dutch translation (WhatsApp Image 2019-05-08 at 18.09.39.jpeg)
After the post, the whole product has changed (so no updated translation) (WhatsApp Image 2019-05-08 at 18.09.04.jpeg)

So we need to update the product instead of adding a new one (PUT instead of POST), but when we do a PUT (with the same request) we get an error (WhatsApp Image 2019-05-08 at 18.09.04.jpeg)

When we looked at the code (hidden link)

You see that the fucntion set_product_language only accepts a POST

May 10, 2019 at 2:17 pm #3785383

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

I've asked our 2nd tier about this - I'll get back to you as soon as I have any news or questions for you.

Regards,
Bruno Kos

May 13, 2019 at 10:17 am #3796801

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

This has been escalated to our 2nd Tier team and may take some debugging time, I'll get back to you as soon as I have any news or questions for you.

Regards,
Bruno Kos

May 15, 2019 at 8:33 am #3813639

yoshiP

Any update on this?

May 15, 2019 at 8:42 am #3813749

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

This issue has been escalated to WPML developers. As for fixing it, I can't give you any dates, it could end up in the next release or in 6 months. This is totally up to developers - severity of the issue and number of reported cases (among other things) decide its queue on the list.

I will keep this thread updated as soon as I get any new information from them!

Regards,
Bruno Kos

May 27, 2019 at 2:14 pm #3898213

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Version 4.6.3. has been released and it should include this fix:
https://wpml.org/download/woocommerce-multilingual/?section=changelog

Specifically, it includes (among other things):
Fix “set_product_language” REST API call not supported “PUT” method

Can you tell me if the issue was resolved?

Regards,
Bruno Kos