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.
- Edit wp-content/plugins/woocommerce-multilingual/classes/Reviews/Translations/FrontEndHooks.php file.
- 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 ); }
- Then open go to: wp-content/plugins/woocommerce-multilingual/classes/Reviews/Translations/Mapper.php file.
- 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 ); }
- Finally, go to WooCommerce → WooCommerce Multilingual → Status and click on the Troubleshooting link.
- Select Register product reviews for translations.
- Click on the Start button.