This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is developing a site using WPML to manage product translations and has created a custom plugin to fetch and migrate products from another WooCommerce WPML store. The issue arises when duplicating a product for another language, as it requires manual selection of 'Translate independently' due to WPML maintaining the product, causing both languages to get translated simultaneously when synchronized.
Solution:
We recommend using a custom code approach to automate the process of setting duplicated products to 'Translate independently'. Here is a step-by-step guide on how to implement this:
global $wpdb;<br />$table_name = $wpdb->prefix . 'icl_translations';<br />$product_ids = $wpdb->get_col("SELECT element_id FROM $table_name WHERE element_type = 'post_product'");<br />foreach ($product_ids as $product_id) {<br /> do_action('wpml_make_post_duplicates', $product_id);<br /> do_action('wpml_set_element_translation', 'post_product', $product_id, [<br /> apply_filters('wpml_default_language', NULL) => $product_id,<br /> apply_filters('wpml_secondary_language', NULL) => $product_id,<br /> ]);<br />}
This code should be triggered with a CTA for test purposes. If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.
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 2 replies, has 2 voices.
Last updated by 10 months, 1 week ago.
Assisted by: Mihai Apetrei.