WPML
Status
Resolvido
Relatado para
WPML Multilingual & Multicurrency for WooCommerce 4.12.6
Resolvido em
WooCommerce Multilingual & Multicurrency 5.5.2

Visão geral do problema

O WPML Multilingual & Multimoeda para WooCommerce agora permite que você traduza e exiba avaliações de produtos. No entanto, ainda não é possível traduzir as respostas a essas avaliações.

Solução alternativa

Por favor, faça um backup completo do seu site antes de prosseguir.


  1. Edite o arquivo wp-content/plugins/woocommerce-multilingual/classes/Reviews/Translations/FrontEndHooks.php.

  2. Substitua:
    	private static function isNonEmptyReview( $comment ) {
    		return Obj::prop( 'comment_content', $comment )
    		       && Relation::propEq( 'comment_type', self::COMMENT_TYPE, $comment );
    	}

    Por:

    	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. Em seguida, abra o arquivo: wp-content/plugins/woocommerce-multilingual/classes/Reviews/Translations/Mapper.php.

  4. Substitua:
    	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 );
    	}

    Por:

    	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. Por fim, vá para WooCommerceWooCommerce MultilingualStatus e clique no link Solução de problemas.

  6. Selecione Registrar avaliações de produtos para traduções.

  7. Clique no botão Iniciar.

Todos os problemas conhecidos →