WPML
Status
Resolved
Type
Bug
Reported for
WPML Multilingual & Multicurrency for WooCommerce 5.3.9
Resolved in
WPML Multilingual & Multicurrency for WooCommerce 5.6.0
Topic tags
Bug, WCML

Overview of the issue

WPML Multilingual & Multicurrency for WooCommerce correctly translates product reviews when displayed under the Reviews tab on single product pages. However, when using WooCommerce’s Reviews blocks, translated reviews are not shown. Instead, the original-language reviews are displayed.

Workaround

Update to WPML Multilingual & Multicurrency for WooCommerce 5.6.0 or later. Translated reviews now show in the WooCommerce review blocks too. After updating, remove the snippet below from your theme if you added it.

If you cannot update yet:

Please, make sure of having a full site backup of your site before proceeding.
  • Open your theme’s functions.php file.
  • Add the following snippet:
    add_filter( 'get_comment', 'translate_comment' );
    function translate_comment( $comment ){
    
        if ( !is_singular('product') && isset( $comment->comment_type ) && $comment->comment_type === 'review' && isset( $comment->comment_content ) ) {
            $name = 'product-'.$comment->comment_post_ID.'-review-'.$comment->comment_ID;
            $comment->comment_content = apply_filters( 'wpml_translate_single_string', $comment->comment_content, 'wcml-reviews', $name );
        }
        
        return $comment;
    }

All known issues