Answer the question
In order to leave comments, you need to log in
Bitrix smart filter multicurrency?
Good afternoon!
I ask for help in implementing multi-currency in a smart filter, namely in the output in the fields for entering "Price FROM - TO" prices in another currency!
I successfully implemented the output in another currency in the product card using CCurrencyRates::ConvertCurrency() using the selector, I change the display of prices there.
But the smart filter in the input fields became a problem for me...
In the input in the template, I replaced the value with
$price_min = round(CCurrencyRates::ConvertCurrency($arItem["VALUES"]["MIN"]["VALUE"], 'RUB', 'USD'), 2);
$price_min_html = round(CCurrencyRates::ConvertCurrency($arItem["VALUES"]["MIN"]["HTML_VALUE"], 'RUB', 'USD'), 2);
value="<?=($price_min_html) ? $price_min_html : ($price_min)?>"
data-price="<?=$price_min;?>"
Answer the question
In order to leave comments, you need to log in
Because whereHas works for querying Result. with works after this request. Therefore, you must also write this condition in with
The smart filter filters only the fields specified by the values.
Those. if the filter is by the price property with the ruble currency, then the filtering will be only by the ruble, and customizing the component, and even more so the template, is very labor-intensive.
It will be much easier to add additional price types - USD Price , EUR Price , etc.
Hang a handler for changing/adding a product, in which these types of prices will be automatically filled in from the conversion from the ruble at the internal exchange rate.
Next, in the smart filter, display all the necessary price types using standard tools, and slightly customize the template so that only the Ruble is displayed by default, then the necessary price types are shown by select.
UPD
If you have the Small Business edition, then there will be no multi-price.
In this case, you will have to customize the filter component:
1. Move the component to a separate space
2. Enter the exchange rate somewhere
3. In the component template, where the block for filtering by price is displayed, add a select, with the choice of the desired currency, when changing the currency, through ajax, recalculate prices at the rate, and display in the same place.
+ add input:hidden with the selected currency
4. In the component, check the incoming rate, and convert to rubles.
As a result, everything will work on top of the standard functionality.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question