This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is experiencing issues with ACF fields in a multilingual WooCommerce setup using WPML. Specifically, when updating a product in a secondary language, fields such as repeaters and relationship fields incorrectly inherit or duplicate content from the primary language product, despite being set to 'Copy once'.
Solution:
We recommend the following steps to address the issue:
1. Create a full backup of the site.
2. Navigate to
wp-content/plugins/sitepress-multilingual-cms/classes/custom-field-translation/class-wpml-copy-once-custom-field.php
and edit the
WPML_Copy_Once_Custom_Field::copy
method.
3. Replace the existing code with the following:
if ( ! get_post_meta( $post_id, 'copyoncedone' ) == 1 ) {<br /> add_post_meta($post_id, 'copyoncedone', 1 );<br /> foreach ( $custom_fields_to_copy as $meta_key ) {<br /> $values = isset( $custom_fields[ $meta_key ] ) ? $custom_fields[ $meta_key ] : [];<br /> if ( ! empty( $values ) ) {<br /> $values = array( $values );<br /> }<br /> $values = apply_filters(<br /> 'wpml_custom_field_values',<br /> $values,<br /> [<br /> 'post_id' => $post_id,<br /> 'meta_key' => $meta_key,<br /> 'custom_fields_translation' => WPML_COPY_ONCE_CUSTOM_FIELD,<br /> ]<br /> );<br /><br /> if ( empty ( $values ) && $source_element_id ) {<br /> $this->sitepress->sync_custom_field( $source_element_id, $post_id, $meta_key );<br /> }<br /> }<br />}
4. Save the changes and verify if the issue is resolved.
If this solution does not apply to your case, or if it becomes 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 the problem persists, please open a new support ticket.
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.