Skip Navigation

Open

Reported for: WooCommerce Multilingual & Multicurrency 4.12.6

Overview of the issue

WooCommerce Multilingual allows you now to translate and display product reviews. However, it is not possible yet to translate responses to those reviews.

Workaround

Please, make a full backup of your site before proceeding.

  1. Edit wp-content/plugins/woocommerce-multilingual/classes/Reviews/Translations/FrontEndHooks.php file.
  2. Replace:
    	private static function isNonEmptyReview( $comment ) {
    		return Obj::prop( 'comment_content', $comment )
    		       && Relation::propEq( 'comment_type', self::COMMENT_TYPE, $comment );
    	}
    

    With:

    	private static function isNonEmptyReview( $comment ) {
    		return Obj::prop( 'comment_content', $comment )
    		       && Relation::propEq( 'comment_type', self::COMMENT_TYPE, $comment ) || Relation::propEq( 'comment_type', 'comment', $comment );
    	}
    
  3. Then open go to: wp-content/plugins/woocommerce-multilingual/classes/Reviews/Translations/Mapper.php file.
  4. Replace:
    	private function getUnregisteredReviews() {
    		// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
    		$q = "SELECT c.comment_ID, c.comment_post_ID, c.comment_content, c.comment_type, tr.language_code, st.name, st.value
    				FROM {$this->wpdb->comments} AS c
    				LEFT JOIN {$this->wpdb->prefix}icl_translations AS tr
    					ON tr.element_id = c.comment_post_ID AND tr.element_type = 'post_product'
    				LEFT JOIN {$this->wpdb->prefix}icl_strings AS st
    					ON c.comment_content = st.value
    						AND st.context = '" . FrontEndHooks::CONTEXT . "'
    				WHERE c.comment_type = '" . FrontEndHooks::COMMENT_TYPE . "'
    					AND st.name IS null";
    
    		return (array) $this->wpdb->get_results( $q );
    	}
    

    With:

    	private function getUnregisteredReviews() {
    		// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
    		$q = "SELECT c.comment_ID, c.comment_post_ID, c.comment_content, c.comment_type, tr.language_code, st.name, st.value
    				FROM {$this->wpdb->comments} AS c
    				LEFT JOIN {$this->wpdb->prefix}icl_translations AS tr
    					ON tr.element_id = c.comment_post_ID AND tr.element_type = 'post_product'
    				LEFT JOIN {$this->wpdb->prefix}icl_strings AS st
    					ON c.comment_content = st.value
    						AND st.context = '" . FrontEndHooks::CONTEXT . "'
    				WHERE c.comment_type = '" . FrontEndHooks::COMMENT_TYPE . "' OR c.comment_type = 'comment'
    					AND st.name IS null";
    
    		return (array) $this->wpdb->get_results( $q );
    	}
    
  5. Finally, go to WooCommerce → WooCommerce MultilingualStatus and click on the Troubleshooting link.
  6. Select Register product reviews for translations.
  7. Click on the Start button.

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>