Freelance projects › Настроить фильтр/сортировку по цене на мультивалютном WooCommerce Настроить фильтр/сортировку по цене на мультивалютном WooCommerceclosed without completion
Ответ саппорта по плагину:
What you wrote is correct. The price filter runs a query directly on the database, taking into account only the _price attribute of a product, which is the price in shop's base currency. Prices in other currencies might not exist in the database, as they are calculated dynamically, therefore the price filter query would not be able to access them.
As of today, there isn't an official fix for this kind of issue. From a purely technical perspective, there are two solutions, but they are impractical to implement:
1. Altering the filter query and query the database directly
Generate, for each product, a _price meta for each currency (e.g. _price_USD, _price_EUR, _price_GBP, etc), then alter the price filter query to read the appropriate prices. The drawback of this solution is that all the prices, in all currencies would have to be updated every time the exchange rates are modified, products are imported, products are modified, and so on. This operation could be extremely heavy, especially for complex products (e.g. variable products with many variations), and could make the too slow until the recalculation is completed.
2. Generating the filter results dynamically
This approach would involve skipping the price filter query altogether. Instead, all the products would be loaded, and filtered out one by one, by checking their price on the fly, instead of using SQL. The result could then be cached, for better performance.
The advantage of this solution is that it would not require a full recalculation of all product prices in one go when the exchange rates are updated. However, the filtering would first be performed using a loop, before being cached, and that could be slow, depending on the amount of products.
Both solutions are not optimal, as they could have a significant impact on the site's performance, and that is the reason why we haven't implemented them. However, they would be the only ways to implement an accurate, currency-specific filtering.
As of today, we are not aware of a price filter widget that implements either solution. It would have to be developed from scratch (we can provide an example for the second algorithm, if you are familiar with coding).
Diego - Aelia Support