Resolved
Resolved in: 4.10.0
Overview of the issue
Due to malformed data saved in the database, it happens that product attribute label translations are not displayed on the product page.
Workaround
We are working on a fix for this issue, in the meanwhile, you can use the following patch, please do that only on a test site and if you are comfortable with editing PHP code and only after you have made sure you have a fully working backup of your site.
The follwoing patch is to be appllied in the file “wp-content/plugins/woocommerce-multilingual/inc/class-wcml-attributes.php” on line 379:
Replace the following code (the whole method “get_attr_label_translations”):
public function get_attr_label_translations( $product_id, $lang = false ) { $trnsl_labels = get_post_meta( $product_id, 'attr_label_translations', true );</code> if ( ! is_array( $trnsl_labels ) ) { $trnsl_labels = []; } if ( isset( $trnsl_labels[ $lang ] ) ) { return $trnsl_labels[ $lang ]; } return $trnsl_labels; }
With:
public function get_attr_label_translations( $product_id, $lang = false ) { $trnsl_labels = get_post_meta( $product_id, 'attr_label_translations', true ); $remove_empty_values = function ( $values ) { return wpml_collect( $values )->filter()->toArray(); }; if ( ! $lang && is_array( $trnsl_labels ) ) { return wpml_collect( $trnsl_labels ) ->map( $remove_empty_values ) ->toArray(); } if ( isset( $trnsl_labels[ $lang ] ) ) { return $remove_empty_values( $trnsl_labels[ $lang ] ); } return []; }
WPML 4.4.0 Beta
We’ve releassed a beta which should solve this issue. Please, keep in mind that it is a beta version which is under testing and shouldn’t be used in production sites. You can download it here:
Hi,
i have a problem with function wpml_collect – “Uncaught Error: Call to undefined function wpml_collect()”
Could you please tell me how to solve this problem?
Hello Karol,
We’ve slightly modified the erratum making more readable the workaround. Our next version of WCML should include this fix, however, you can try again this solution and open a ticket in our support forum if still it does not work:
https://wpml.org/forums/forum/english-support/
Regards,
Andrés
Problem solved with this queries:
DELETE FROM `wp_postmeta` WHERE `meta_key` = 'attr_label_translations' AND meta_value LIKE '%a:1:%'
and
DELETE FROM `wp_postmeta` WHERE `meta_key` = 'attr_label_translations' AND meta_value LIKE '%a:1:%'
I’m glad it worked for you, but we can’t’t recommend you this approach.
Have you tried our WooCommerce Multilingual Beta 4.10.0-b.2 on your staging site?
If the issue remains, please open a ticket in our support forum, we would like to investigate your case as we are still in Beta.
https://wpml.org/forums/forum/english-support/
Hello, is this connected to the issue that the attributes in woocommerce multilingual does not show after selecting? It keeps endless spinning with the devtool error:
Uncaught TypeError: Cannot read property 'label' of undefine
screenshot backend woo multilingual
Thank you for reporting this! However I can’t replicate it. Could you please try our WooCommerce Multilingual Beta 4.10.0-b.2 on your staging site?
If the issue remains, please open a ticket in our support forum, we would like to investigate your case as we are still in Beta.
https://wpml.org/forums/forum/english-support/
Thank you for your help!
Andrés
By the way, please share your support link here or add a note on it so we can follow it better.
Thanks again.
Sorry, the support I opened happened after I figured out that the above solution did not help my attribute problem. Support Ticket – Attributes not loading.
Thanks for sharing that link. I’m glad to know it is solved now. 🙂