- Status
- 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:
https://wpml.org/account/downloads/