/** * @deprecated deprecated since catalog 15.0.0 * @see CCatalogDiscount::applyDiscountList() * @see CCatalogDiscount::calculatePriorityLevel() */ protected static function __CalcOnePriority(&$arDiscounts, &$arResultDiscount, &$arParams) { $boolResult = false; if (isset($arParams['PRICE']) && isset($arParams['CURRENCY'])) { $arParams['PRICE'] = (double) $arParams['PRICE']; $arParams['BASE_PRICE'] = (double) $arParams['BASE_PRICE']; if ($arParams['PRICE'] > 0) { $dblCurrentPrice = $arParams['PRICE']; do { $dblMinPrice = -1; $strMinKey = -1; $boolLast = false; $boolApply = false; foreach ($arDiscounts as $strDiscountKey => $arOneDiscount) { $boolDelete = false; $dblPriceTmp = -1; switch ($arOneDiscount['VALUE_TYPE']) { case CCatalogDiscount::TYPE_PERCENT: $dblTempo = roundEx((CCatalogDiscount::getUseBasePrice() ? $arParams['BASE_PRICE'] : $dblCurrentPrice) * $arOneDiscount['VALUE'] / 100, CATALOG_VALUE_PRECISION); if (isset($arOneDiscount['DISCOUNT_CONVERT'])) { if ($dblTempo > $arOneDiscount['DISCOUNT_CONVERT']) { $dblTempo = $arOneDiscount['DISCOUNT_CONVERT']; } } $dblPriceTmp = $dblCurrentPrice - $dblTempo; break; case CCatalogDiscount::TYPE_FIX: if ($arOneDiscount['DISCOUNT_CONVERT'] > $dblCurrentPrice) { $boolDelete = true; } else { $dblPriceTmp = $dblCurrentPrice - $arOneDiscount['DISCOUNT_CONVERT']; } break; case CCatalogDiscount::TYPE_SALE: if (!($arOneDiscount['DISCOUNT_CONVERT'] < $dblCurrentPrice)) { $boolDelete = true; } else { $dblPriceTmp = $arOneDiscount['DISCOUNT_CONVERT']; } break; } if ($boolDelete) { unset($arDiscounts[$strDiscountKey]); } else { if (-1 == $dblMinPrice || $dblMinPrice > $dblPriceTmp) { $dblMinPrice = $dblPriceTmp; $strMinKey = $strDiscountKey; $boolApply = true; } } } if ($boolApply) { $dblCurrentPrice = $dblMinPrice; $arResultDiscount[] = $arDiscounts[$strMinKey]; if ('Y' == $arDiscounts[$strMinKey]['LAST_DISCOUNT']) { $arDiscounts = array(); $arParams['LAST_DISCOUNT'] = 'Y'; } unset($arDiscounts[$strMinKey]); } } while (!empty($arDiscounts)); if ($boolApply) { $arParams['PRICE'] = $dblCurrentPrice; } $boolResult = true; } } return $boolResult; }