• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/discount/actions.php
  • Класс: BitrixSaleDiscountActions
  • Вызов: Actions::setUseMode
static function setUseMode($mode, array $config = array())
{
	$mode = (int)$mode;
	if ($mode !== self::MODE_CALCULATE && $mode !== self::MODE_MANUAL && $mode !== self::MODE_MIXED)
		return;
	self::$useMode = $mode;
	switch (self::$useMode)
	{
		case self::MODE_CALCULATE:
			$percentOption = (string)MainConfigOption::get('sale', 'get_discount_percent_from_base_price');
			self::$percentValueMode = ($percentOption == 'Y' ? self::PERCENT_FROM_BASE_PRICE : self::PERCENT_FROM_CURRENT_PRICE);
			unset($percentOption);
			if (isset($config['CURRENCY']))
				self::$currencyId = $config['CURRENCY'];
			if (isset($config['SITE_ID']))
			{
				self::$siteId = $config['SITE_ID'];
				if (self::$currencyId == '')
					self::$currencyId = SaleInternalsSiteCurrencyTable::getSiteCurrency(self::$siteId);
			}
			break;
		case self::MODE_MANUAL:
		case self::MODE_MIXED:
			$percentOption = '';
			if (isset($config['USE_BASE_PRICE']))
				$percentOption = $config['USE_BASE_PRICE'];
			if ($percentOption == '')
				$percentOption = (string)MainConfigOption::get('sale', 'get_discount_percent_from_base_price');
			self::$percentValueMode = ($percentOption == 'Y' ? self::PERCENT_FROM_BASE_PRICE : self::PERCENT_FROM_CURRENT_PRICE);
			unset($percentOption);
			if (isset($config['CURRENCY']))
				self::$currencyId = $config['CURRENCY'];
			if (isset($config['SITE_ID']))
			{
				self::$siteId = $config['SITE_ID'];
				if (self::$currencyId == '')
					self::$currencyId = SaleInternalsSiteCurrencyTable::getSiteCurrency(self::$siteId);
			}
			break;
	}
	static::clearApplyCounter();
	static::enableBasketFilter();
}