This thread is resolved. Here is a description of the problem and solution.
Problem:
If you're using
apply_filters('wpml_copy_post_to_language')
to create translations of products and find that it does not copy product attributes, you might encounter difficulties in achieving complete product translations.
Solution:
First, ensure that in WPML > Settings, under Taxonomy translation, the translation preference for Attributes is set to "Copy". If this does not resolve the issue, you can manually copy product attributes using custom code. Here's a step-by-step guide:
1. Create an independent translation of the post in the target language using
$translated_post_id = apply_filters('wpml_copy_post_to_language', $product->get_id(), $target_language, false);
2. Retrieve the translated product with
$translated_product = wc_get_product($translated_post_id);
3. Get attributes from the original product with
$attributes = $product->get_attributes();
4. Set these attributes to the translated product with
$translated_product->set_attributes($attributes);
5. Save the translated product with
$translated_product->save();
If you need further customization, consider hiring a developer from WPML Contractors.
Please note that this solution might be outdated or not applicable to your specific case. 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 the issue persists, 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 1 reply, has 2 voices.
Last updated by Prosenjit Barman 2 months, 3 weeks ago.
Assisted by: Prosenjit Barman.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.