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.

This topic contains 14 replies, has 2 voices.

Last updated by Alejandro 4 months, 2 weeks ago.

Assigned support staff: Alejandro.

Author Posts
March 11, 2022 at 10:16 am #10766969

tomasA-11

Tell us what you are trying to do?

Im trying to add product translations of variable products with local attributes so that the translated local attributes are linked per variation.

Right now im using the woocommerce API to add variable products and it automatically copies the main language attribute to the other languages and variations as well and when i try to add a translated attribute it results in all attributes dissapearing from that language.

Is there any documentation that you are following?

https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/

Is there a similar example that we can see?

Dont know

What is the link to your site?

hidden link

March 12, 2022 at 11:24 am #10774461

Alejandro
Supporter

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

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

The local attributes need to be translated in order for them to be on the translated languages.

So you need to make sure you translate it. REST is in the "custom coding" area so we won't be able to fully help there, since it's out of the scope of our support but you might want to take a look at this guide and it's variable products examples: https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/

This one for example, might suit your case: https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/#create-product-variations-with-local-attribute

-------------------------

However there's something else that i might not be understanding at the moment.

i think you want to independently add attributes ONLY to one language and if that's the case, please know it's not possible. the attributes must be the same that you add on the original product.

they should be added to the original product first after they have been translated and then translate the product so the attributes are synced.

If you are translating the attributes after having translated the product, you might want to go to WooCommerce > WooCommerce Multilingual > Settings > Troubleshooting and run the "duplicate attributes" options and also the different "sync" options you'll see on that page.

Regards.

March 16, 2022 at 8:50 am #10800077

tomasA-11

So how do you translate the attributes ?

March 16, 2022 at 2:44 pm #10804901

Alejandro
Supporter

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

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

If you're using REST, then you can use the link that i sent above: https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/#create-product-variations-with-local-attribute

you can take it from there to see what to do in your particular case afterwards.

-------------------

If you're NOT using REST, then just send the product with the local attribute to translate using our standard procedure as seen here: https://wpml.org/documentation/translating-your-contents/

Regards.

March 17, 2022 at 2:48 pm #10813583

tomasA-11

The solution in the first link wont work because we are using local attributes which got no IDs ?

March 17, 2022 at 4:22 pm #10814515

Alejandro
Supporter

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

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

Every single thing in WordPress wether it's a post type element, taxonomy (local or global) will have an ID, it's the "WordPress way" (it applies to WooCommerce).

The attr ID will be found in your postmeta table, you can try searching for it there and i guess you can retrieve it using this, since you know the name: hidden link

( wc_attribute_taxonomy_id_by_name() )

This is already standard WooCommerce programming so it's as far as we can go with it.

Regards.

March 18, 2022 at 2:47 pm #10823529

tomasA-11

I dont think they do. This is how they are stored in the database of a products meta data:

'a:1:{s:11:"valj-finish";a:6:{s:4:"name";s:12:"Välj finish";s:5:"value";s:46:"ABS Svart Struktur | Blanksvart | Kolfiberlook";s:8:"position";i:0;s:10:"is_visible";i:1;s:12:"is_variation";i:1;s:11:"is_taxonomy";i:0;}}'

And I dont know how a function is supposed to get an ID out of a local attribute that is bound only to a product. How does the function know which product to look at ?

March 19, 2022 at 12:58 pm #10828917

Alejandro
Supporter

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

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

We're talking about WooCommerce here, it's not WPML related so i'd suggest that if you are struggling or having doubts about how to get something in WooCommerce, you contact their support since it's out of the scope of ours.

However, i wanted to double check this with an easy test which you can see here: hidden link

i created a product, i set it as a variable product, i created some attributes and i created variations out of them.

in the video you can see there is a post_ID and a meta_ID, so there you should find both the ID of the actual variation for the local attributes (remember that a variation is nothing but another post type in WordPress) and the meta_id which contains in this case the name of the attribute.

The "how" part can be asked to the WooCommerce support since i guess they have hooks or functions for that, but it should be possible.

We can try to help out with the WPML related part, but i'm not sure how else i can help you with the WooCommerce part 🙁

Regards.

March 23, 2022 at 10:58 am #10855881

tomasA-11

Dont think that ID is relevant for using with the coding API.

Regardless of that though, we even tried to translate it in the translation editor with little to no success.

Adding screenshots to illustrate the issue.

translation_page.png
translated_product_page.png
translated_product_attr.png
original_product_attr.png
March 23, 2022 at 2:37 pm #10858527

Alejandro
Supporter

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

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

1) If you do this manually, does it work (with a local attribute, that is). does it sync without issues?

2) If you go to WooCommerce > Woocommerce Multilingual > Settings > Troubleshooting and run all the options there (specially the "sync" ones), one by one. does anything change in the problematic products?

3) If you manually add a character to the original product, save it and translate it again or update its translations. does anything change?

These 3 questions are going to help me understand where the problem might lie so i can understand how to move forward.

March 24, 2022 at 5:35 pm #10870881

tomasA-11

1) If I do it manually on a manually created product it translates almost as we want it to.

2) Cant find the "Troubleshooting" part under WooCommerce > Woocommerce Multilingual > Settings im afraid.

3) If I change one character in the description of the original product the translation resets in the translated product and becomes what was originally typed there instead. If I then redo the translation on the translation page it displays the translation again but removed all variations.

troubleshooting-option-not-found.png
Translation-page.png
translated-product-variations-after-translation.png
translated-product-product-page.png
Translated-product-attributes.png
original-products-variations.png
original-products-attributes.png
March 26, 2022 at 9:01 am #10881805

Alejandro
Supporter

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

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

To continue, I'll need temporary access to your site.

I have just activated the appropriate boxes for the credential information i need from you. they are private so only you and i will be able to see them.

I suggest you create a temporary user, set it as an administrator and then add those credentials in the fields mentioned above.

March 26, 2022 at 2:34 pm #10882879

Alejandro
Supporter

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

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

Please check this video: hidden link

in there i noticed there are a few things that need to be done or fixed in WooCommerce > WooCommerce Multilingual > Status , and the same path but for the "Store URLs" tab.

- Please make sure everything in the status page shows as ok.
- The shop page slug or label and the "product" base slug CAN'T be the same and right now they are.
- The same applies to the translations, they should all be different from each other.
- The product base slug is not translated yet, so please translate it accordingly.

Then, i tried to recreate a variable product with local attributes and they are all created normally. so far WPML works without issues.

-------------------

I know that your problem has to do about doing it with the API. i actually tested this before with one of our devs and we successfully created a variable product with a local attribute.

HOWEVER the only restriction we have is about translating the attribute LABEL, but not the attribute Term.

so if you have an attribute "color" with terms "blue, red", you can translate blue and red without issues through the API but not "color" because that's something that's translated usually via String translation (From global attributes) or via the translation editor (if we talk about local attributes).

It's the only restriction we currently have.

-------------------------------

If, after you fix all i mentioned in the video and in the list below the video link and you still can't make it work, then:

- Disable all the plugins on the site except WooCommerce and our WPML plugins
- Try to create a new variable product with local attributes
- Try to see if they are created successfully and if they are also translated

- If you duplicate the product first, let me know
- If you can, try to record yourself while following your usual workflow for this and then send me the video link and the code that handles this procedure.

Regards.

March 28, 2022 at 7:04 pm #10896561

tomasA-11

Thanks Alejandro.
"- The same applies to the translations, they should all be different from each other."
Which translations are you talking about here?

March 29, 2022 at 8:56 am #10900127

Alejandro
Supporter

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

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

I was talking about the slug translations, sorry. in WooCommerce > WooCommerce Multilingual > Store URLs you'll see that you can translate endpoints and slugs. everything in there must be different from the other content.

this means you can't have the same translation for different languages or different elements among the elements shown in that page.

if you have a product post type "product", you can't have the shop base slug as "product" nor you can't have another translation using "product".

this is done to avoid conflicts in WooCommerce that could create weird redirections or overall problems in the site.

Regards.