Skip Navigation

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

Problem:
If you're experiencing issues with product variations disappearing or being duplicated in different languages after updating WooCommerce Multilingual, it might be due to a language mismatch in the icl_translations table.

Solution:
First, ensure that the post type

product_variation

is set to "Translatable - only show translated items" in WPML > Settings > Post Types Translation. If the variations are still incorrect, you may need to:
1. Remove all translated variations. This can be done by removing all translated products, which will also remove their variations.
2. Change the language of the affected variations to match the original product language using an SQL query:

#First we obtain the language and store it as a variable
SET @language_code = ( SELECT language_code FROM wp_icl_translations WHERE element_type = 'post_product' AND source_language_code IS NULL LIMIT 1 );
 
#We get here the post_product IDs for ease of use
CREATE TEMPORARY TABLE temp_ids AS
SELECT element_id
FROM wp_icl_translations
WHERE element_type = 'post_product' AND source_language_code IS NULL;
 
# We update the post_product_variations based on the post_parent in wp_posts
UPDATE wp_icl_translations
SET language_code = @language_code
WHERE element_id IN (
SELECT ID
FROM wp_posts
WHERE post_parent IN (SELECT element_id FROM temp_ids)
) AND element_type LIKE "post_product_variation";
 
#Here we clear the temporary table so that we leave no trace
DROP TEMPORARY TABLE IF EXISTS temp_ids;

Alternatively, you can remove and re-create the variations in the original language products.
3. After making these changes, you can update WooCommerce Multilingual to the latest version and re-update products in the original language.

Please ensure you back up your database and website before making any changes. If the variations are still not displaying correctly after following these steps, you may need to re-translate the product to ensure the variations are correct in the secondary languages.

If this solution does not apply to your situation, or if it seems outdated, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket with us.

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 6 replies, has 2 voices.

Last updated by Long Nguyen 8 months ago.

Assisted by: Long Nguyen.

Author Posts
April 25, 2024 at 6:59 am

Rick Hunnersen

Hi there, I'm currently still on the WooCommerce Multilingual & Multicurrency 5.3.2 version since I can't update to the newest one. Updating breaks my product page variations. When I update to the newest version and change something on a product page, the product variation disappear and can not be added again.

April 25, 2024 at 8:19 am
April 25, 2024 at 8:22 am #15564088

Rick Hunnersen

Backup before update:

hidden link

April 25, 2024 at 8:36 am #15564122

Long Nguyen
Supporter

Languages: English (English )

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

I'm downloading the backup file and restoring your site on my local host to investigate the issue. I will update you here when I have something to share.

Thanks.

April 25, 2024 at 8:58 am #15564309

Rick Hunnersen

Thanks, keep me updated.

April 26, 2024 at 2:39 am #15567612

Long Nguyen
Supporter

Languages: English (English )

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

Hi,

There is an issue with the language of the variation in the table icl_translations. The original language of the product is Dutch (nl) but in that table, it is English (en) and causes the issue.
I'm discussing this issue with our 2nd tier support and update you here when I have more information.

Thanks.

localhost_8888 _ localhost _ rhunt _ wp_icl_translations _ phpMyAdmin 5.2.0 2024-04-25 17-08-49.jpg
Edit product “Travel x Tshirt” ‹ Amsterdam Genetics — WordPress 2024-04-25 17-05-11.png
April 26, 2024 at 7:09 am #15568011

Rick Hunnersen

Hi Long,

That's very interesting, hopefully this is the issue. Let me know if you find a solution.

May 9, 2024 at 3:54 am #15608308

Long Nguyen
Supporter

Languages: English (English )

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

Hi Rick,

After discussing and investigating the issue on your site, we have some suggestions for you to fix the issue with product variation in the original language Dutch.

The issue could arise when the post type product_variation is set to "Not translatable" in WPML > Settings > Post Types Translation. And causes the wrong language of all variation products including translations.
Related ticket https://wpml.org/forums/topic/retranslate-product-varations/

This isn't a bug in WPML or WooCommerce Multilingual because that post type must be set to "Translatable" by default. As a result, the variations are not assigned to the proper language.
For example, if we take the product with ID 74169 We will see that it is a product in Dutch. It is translated and for example, if we take one of its translations - ID 74173 we can see that both 74169 and 74173 have 3 variations.
74169 -> 74170, 74171, 74172
74173 -> 76151, 76152, 76153
However if you check the variation ID for example - 74170, you will see that it is not any of the supposed other variations and the other variation IDs are all originals and not a translation and hence they are not linked by TRID.

I did the tests before updating locally to the latest WooCommerce Multilingual. I can say that the update won't do anything that would corrupt things like that.

What we can suggest at this time:

1. Set the post type product_variation to "Translatable - only show translated items".

2. Removing all translated variations (this can be hard but removing all translated products will remove them as well so this is the easiest solution).

3. Changing the language of the affected variations so that they match. Because ID 74169 is in 'nl' language, but the variations 74170, 74171, 74172 are in 'en' language
You can use this SQL query:

#First we obtain the language and store it as a variable
SET @language_code = ( SELECT language_code FROM wp_icl_translations WHERE element_type = 'post_product' AND source_language_code IS NULL LIMIT 1 );

#We get here the post_product IDs for ease of use
CREATE TEMPORARY TABLE temp_ids AS
SELECT element_id
FROM wp_icl_translations
WHERE element_type = 'post_product' AND source_language_code IS NULL;

# We update the post_product_variations based on the post_parent in wp_posts
UPDATE wp_icl_translations
SET language_code = @language_code
WHERE element_id IN (
SELECT ID
FROM wp_posts
WHERE post_parent IN (SELECT element_id FROM temp_ids)
) AND element_type LIKE "post_product_variation";

#Here we clear the temporary table so that we leave no trace
DROP TEMPORARY TABLE IF EXISTS temp_ids;

OR alternatively, you can just remove and re-create them in the Dutch language products.

4. Then you can update WCML to 5.3.6 and re-update products in the Dutch language.

Note: Please backup your database and website before proceeding. This would keep the product and variations in the original language then you need to re-translate the product to have the correct variation in the second languages.

Looking forward to your reply.
Thanks