• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/discount.php
  • Класс: BitrixSaleDiscount
  • Вызов: Discount::save
public function save()
{
	$result = new Result;
	if (!$this->isOrderExists() || !$this->isBasketNotEmpty())
		return $result;

	if ($this->isUsedDiscountCompatibility())
	{
		if (CompatibleDiscountCompatibility::isRepeatSave())
			return $result;
		$compatibleResult = CompatibleDiscountCompatibility::getResult();
		if ($compatibleResult === false)
			return $result;
		if (empty($compatibleResult))
			return $result;

		$this->setUseMode($compatibleResult['CALCULATE']['USE_MODE']);
		$this->newOrder = $compatibleResult['CALCULATE']['NEW_ORDER'];
		$this->discountsCache = $compatibleResult['DISCOUNT_LIST'];
		$this->couponsCache = $compatibleResult['COUPONS_LIST'];
		$this->discountResult = $compatibleResult['DISCOUNT_RESULT'];
		$this->forwardBasketTable = $compatibleResult['FORWARD_BASKET_TABLE'];
		$this->reverseBasketTable = $compatibleResult['REVERSE_BASKET_TABLE'];
		if ($this->isOrderNew())
		{
			$shipmentResult = $this->loadShipment();
			if (!$shipmentResult->isSuccess())
			{
				$result->addErrors($shipmentResult->getErrors());
				unset($shipmentResult);
				return $result;
			}
			unset($shipmentResult);
			$this->fillShipmentData();
		}
		unset($compatibleResult);
	}

	$result = parent::save();

	return $result;
}