- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/discountbase.php
- Класс: BitrixSaleDiscountBase
- Вызов: DiscountBase::getApplyDiscounts
protected function getApplyDiscounts()
{
$discountApply = array();
$couponApply = array();
if (!empty($this->discountsCache))
{
foreach ($this->discountsCache as $id => $discount)
{
$this->discountResult['DISCOUNT_LIST'][$id] = array(
'ID' => $id,
'NAME' => $discount['NAME'],
'MODULE_ID' => $discount['MODULE_ID'],
'DISCOUNT_ID' => $discount['ID'],
'REAL_DISCOUNT_ID' => $discount['DISCOUNT_ID'],
'USE_COUPONS' => $discount['USE_COUPONS'],
'ACTIONS_DESCR' => $discount['ACTIONS_DESCR'],
'ACTIONS_DESCR_DATA' => $discount['ACTIONS_DESCR_DATA'],
'APPLY' => 'N',
'EDIT_PAGE_URL' => $discount['EDIT_PAGE_URL']
);
$discountApply[$id] = &$this->discountResult['DISCOUNT_LIST'][$id];
}
unset($id, $discount);
}
if (!empty($this->couponsCache))
{
foreach ($this->couponsCache as $id => $coupon)
{
$this->discountResult['COUPON_LIST'][$id] = $coupon;
$this->discountResult['COUPON_LIST'][$id]['APPLY'] = 'N';
$couponApply[$id] = &$this->discountResult['COUPON_LIST'][$id];
}
unset($id, $coupon);
}
if (empty($this->discountResult['APPLY_BLOCKS']))
{
unset($discountApply, $couponApply);
return;
}
foreach ($this->discountResult['APPLY_BLOCKS'] as $counter => $applyBlock)
{
if (!empty($applyBlock['BASKET']))
{
foreach ($applyBlock['BASKET'] as $basketCode => $discountList)
{
foreach ($discountList as $discount)
{
if ($discount['RESULT']['APPLY'] == 'Y')
{
if (isset($discountApply[$discount['DISCOUNT_ID']]))
$discountApply[$discount['DISCOUNT_ID']]['APPLY'] = 'Y';
if (isset($couponApply[$discount['COUPON_ID']]))
$couponApply[$discount['COUPON_ID']]['APPLY'] = 'Y';
}
}
unset($discount);
}
unset($basketCode, $discountList);
}
if (!empty($applyBlock['ORDER']))
{
foreach ($applyBlock['ORDER'] as $discount)
{
if (!empty($discount['RESULT']['BASKET']))
{
foreach ($discount['RESULT']['BASKET'] as $basketCode => $applyList)
{
if ($applyList['APPLY'] == 'Y')
{
if (isset($discountApply[$discount['DISCOUNT_ID']]))
$discountApply[$discount['DISCOUNT_ID']]['APPLY'] = 'Y';
if (isset($couponApply[$discount['COUPON_ID']]))
$couponApply[$discount['COUPON_ID']]['APPLY'] = 'Y';
}
}
unset($basketCode, $applyList);
}
if (!empty($discount['RESULT']['DELIVERY']) && $discount['RESULT']['DELIVERY']['APPLY'] == 'Y')
{
if (isset($discountApply[$discount['DISCOUNT_ID']]))
$discountApply[$discount['DISCOUNT_ID']]['APPLY'] = 'Y';
if (isset($couponApply[$discount['COUPON_ID']]))
$couponApply[$discount['COUPON_ID']]['APPLY'] = 'Y';
}
}
unset($discount);
}
}
unset($counter, $applyBlock);
unset($discountApply, $couponApply);
}