WPML

문제 개요

YITH WooCommerce Compare를 WPML과 함께 사용할 때 보조 언어 페이지에서 다음과 같은 문제가 발생할 수 있습니다:

  • 비교 테이블이 기본 언어로 열립니다.
  • 다른 언어 페이지에서 추가한 제품의 이름이 해당 언어로 표시됩니다.
  • 속성 행에 속성 레이블이 기본 언어로 표시됩니다.
  • 플러그인 스타일시트가 로드되지 않아 버튼과 테이블에 스타일이 적용되지 않습니다.

임시 해결 방법

테마의 functions.php 파일이나 코드 스니펫 플러그인에 이 코드를 추가하세요:

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 );

모든 알려진 문제

이 문제에 대한 도움이 필요하십니까?

지원 문의를 하시면 저희가 함께 살펴보겠습니다.