WPML

Tổng quan về sự cố

Khi sử dụng YITH WooCommerce Compare với WPML, bạn có thể gặp phải các sự cố sau trên các trang ở ngôn ngữ phụ:

  • Bảng so sánh mở ra bằng ngôn ngữ mặc định.
  • Một sản phẩm được thêm trên một trang ở ngôn ngữ khác hiển thị tên bằng ngôn ngữ đó.
  • Các hàng thuộc tính hiển thị nhãn thuộc tính bằng ngôn ngữ mặc định.
  • Stylesheet của plugin không tải, do đó các nút và bảng không có định dạng.

Giải pháp tạm thời

Thêm mã này vào tệp functions.php trong giao diện của bạn hoặc vào một plugin đoạn mã:

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

Tất cả lỗi đã ghi nhận

Cần trợ giúp với vấn đề này?

Đặt một câu hỏi hỗ trợ và chúng tôi sẽ cùng bạn xem xét vấn đề này.