Resolved
Reported for: WPML Multilingual & Multicurrency for WooCommerce 4.12.6
Resolved in: WooCommerce Multilingual & Multicurrency 5.5.2
Overview of the issue
WPML Multilingual & Multicurrency for WooCommerce 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.
This issue exists for multiple years now. Why isn’t this being fixed?
Our developers are aware of this issue and it is in their roadmap although we don’t have an ETA.
We will keep this page updated with any news.