WPML

Visão geral do problema

Ao usar o YITH WooCommerce Compare com o WPML, você pode encontrar os seguintes problemas em páginas em um idioma secundário:

  • A tabela de comparação abre no idioma padrão.
  • Um produto adicionado em uma página em outro idioma mostra seu nome nesse idioma.
  • As linhas de atributos mostram os rótulos dos atributos no idioma padrão.
  • A folha de estilos do plugin não carrega, por isso os botões e a tabela não têm estilos.

Solução alternativa

Adicione este código ao arquivo functions.php do seu tema ou a um plugin de trechos de código:

PHP
// The comparison table opens in the current language.
add_filter( 'yith_woocompare_view_table_url', function ( $url ) {
	return apply_filters( 'wpml_permalink', $url, apply_filters( 'wpml_current_language', null ) );
} );

// The table shows the products of the current language.
add_filter( 'yith_woocompare_products_list', function ( $ids ) {
	return array_values( array_unique( array_map( function ( $id ) {
		return (int) apply_filters( 'wpml_object_id', $id, get_post_type( $id ) ?: 'product', true );
	}, (array) $ids ) ) );
} );

// The attribute rows show the translated attribute labels.
add_filter( 'yith_woocompare_filter_table_fields', function ( $fields ) {
	foreach ( array_keys( (array) $fields ) as $field ) {
		if ( 0 === strpos( (string) $field, 'pa_' ) && taxonomy_exists( $field ) ) {
			$fields[ $field ] = wc_attribute_label( $field );
		}
	}
	return $fields;
} );

// The plugin stylesheet loads on secondary-language pages.
add_filter( 'yith_woocompare_asset_url', function ( $url, $asset_path ) {
	return site_url( '/' . ltrim( (string) $asset_path, '/' ) );
}, 10, 2 );

Todos os problemas conhecidos

Precisa de ajuda com este problema?

Envie uma dúvida de suporte e analisaremos isso com você.