2

I have an issue with creating a translation for a product by WooCommerce Rest API and WPML. the issue is my created translated product did not get linked to the original one. Let's say instead of creating translation for a product it will create a brand new product in default language.

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var urlencoded = new URLSearchParams();
urlencoded.append("translation_of", "354");
urlencoded.append("name", "محصول عربی");
urlencoded.append("lang", "ar");
urlencoded.append("type", "simple");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://domain.localhost/wp-json/wc/v3/products?consumer_key=ck_key&consumer_secret=cs_secret", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

The result will look like:

enter image description here

But the translated product showed in the product list of default language:

enter image description here

And in the Products list, we have them both side by side :)

enter image description here

What am I missing? Why it isn't translated and instead it creates a new product?

montrealist
  • 5,593
  • 12
  • 46
  • 68
Adnan
  • 814
  • 12
  • 38
  • hi @montrealist, i have the same problem but for a custom type. Did you find a way ? – djoo Feb 04 '21 at 17:49
  • @djoo not sure, I know it should work for products if you follow [Create product section here](https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/) - and specify `translation_of ` – montrealist Feb 05 '21 at 15:15
  • thanks for your reply. Unfortunately doesn't work for post. I'm gonna try to find a way :) – djoo Feb 05 '21 at 17:17

0 Answers0