• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/compatible/discountcompatibility.php
  • Класс: BitrixSaleCompatibleDiscountCompatibility
  • Вызов: DiscountCompatibility::getApplyDiscounts
static function getApplyDiscounts()
{
	$discountApply = array();
	$couponApply = array();

	self::$discountResult['DISCOUNT_LIST'] = array();
	if (!empty(self::$discountsCache))
	{
		foreach (self::$discountsCache as $id => $discount)
		{
			self::$discountResult['DISCOUNT_LIST'][$id] = array(
				'ID' => $id,
				'NAME' => $discount['NAME'],
				'MODULE_ID' => $discount['MODULE_ID'],
				'DISCOUNT_ID' => $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] = &self::$discountResult['DISCOUNT_LIST'][$id];
		}
		unset($id, $discount);
	}

	self::$discountResult['COUPON_LIST'] = array();
	if (!empty(self::$couponsCache))
	{
		foreach (self::$couponsCache as $id => $coupon)
		{
			self::$discountResult['COUPON_LIST'][$id] = $coupon;
			self::$discountResult['COUPON_LIST'][$id]['APPLY'] = 'N';
			$couponApply[$id] = &self::$discountResult['COUPON_LIST'][$id];
		}
		unset($id, $coupon);
	}

	if (!empty(self::$discountResult['BASKET']))
	{
		foreach (self::$discountResult['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(self::$discountResult['ORDER']))
	{
		foreach (self::$discountResult['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($discountApply, $couponApply);
}