$rsCurrency = CCurrency::GetList(($b="name"), ($order1="asc"), LANGUAGE_ID);
while($arCur = $rsCurrency->Fetch())
{
$arCurrency[$arCur["CURRENCY"]] = $arCur["AMOUNT"];
$arCurrencyName[]= $arCur["CURRENCY"];
}
$userCurrency = $_COOKIE["CURRENCY"]; //Валюта установленная на сайте юзером
$userInterval = 1;
if(!in_array($userCurrency, $arCurrencyName))
$userCurrency = intval($_GET["PRICE_INTERVAL"]);
$VAT = 0.18; //НДС
//$VAT = CCatalogVat::GetList(array(), array('ID' => 1));
$priceIntervals = array(
array("1","100"),
array("100","200"),
array("200","300"),
);
foreach ($arCurrency as $curName => $curValue):
$newInterval = array();
foreach ($priceIntervals as $price):
$start = round($price[0]*$arCurrency[$userCurrency]/ ($arCurrency[$curName]*($VAT+1)), 2);
$end = round($price[1]*$arCurrency[$userCurrency]/ ($arCurrency[$curName]*($VAT+1)), 2);
$newInterval[]= array( $start, $end);
endforeach;
$priceIntervalsCurrency[$curName] = $newInterval;
endforeach;
$priceFilter = array( "LOGIC" => "OR" );
foreach ($priceIntervalsCurrency as $curName => $interval) {
$priceFilter[] = array(
">=CATALOG_PRICE_1" => $interval[$userInterval][0],
"<=CATALOG_PRICE_1" => $interval[$userInterval][1],
"CATALOG_CURRENCY_1" => $curName
);
} |