WPML
Trạng thái
Đã giải quyết
Được báo cáo cho
WPML Multilingual & Multicurrency for WooCommerce 5.1.2
Đã giải quyết trong
WCML 5.2.0
Plugin/giao diện liên quan
WooCommerce
Thẻ chủ đề
Bug

Tổng quan về lỗi

Khi sử dụng tính năng đa tiền tệ của WPML Multilingual & Multicurrency for WooCommerce, widget Lọc theo giá hiển thị phạm vi giá không chính xác cho các loại tiền tệ phụ. Nó luôn hiển thị phạm vi của loại tiền tệ mặc định.

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

Vui lòng đảm bảo tạo bản sao lưu đầy đủ cho trang web của bạn trước khi tiếp tục.


  • Thêm đoạn mã sau vào tệp functions.php trong giao diện của bạn:
    use function WCML\functions\getClientCurrency;
    use function WPML\Container\make;
    
    add_filter( 'rest_request_after_callbacks', function( $response, $handler, $request ) {
    
    	if (
    		wcml_is_multi_currency_on()
    		&& 'GET' === $request->get_method()
    		&& 'products/collection-data' === substr( $request->get_route(), -24 )
    		&& ! empty( $request['calculate_price_range'] )
    	) {
    		$mc = make( \WCML_Multi_Currency::class );
    		$from_currency = $mc->get_default_currency();
    		$to_currency = getClientCurrency();
    		$data = $response->get_data();
    		$data['price_range']->min_price = $mc->prices->convert_price_amount( $mc->prices->unconvert_price_amount( $data['price_range']->min_price, $from_currency ), $to_currency );
    		$data['price_range']->max_price = $mc->prices->convert_price_amount( $mc->prices->unconvert_price_amount( $data['price_range']->max_price, $from_currency ), $to_currency );
    		$response->set_data( $data );
    	}
    
    	return $response;
    }, 10, 3 );

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