Resolved
Reported for: WooCommerce Multilingual & Multicurrency 5.1.2
Resolved in: WCML 5.2.0
Overview of the issue
When using WooCommerce Multilingual’s multi-currency feature, the Filter per Price widget displays an inaccurate price range for secondary currencies. It always displays the default currency’s range.
Workaround
Please, be sure of making a full backup of your site before proceeding.
- Add the following snippet in your theme’s functions.php file:
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 );