• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/internals/discountcoupon.php
  • Класс: BitrixSaleInternalsDiscountCouponTable
  • Вызов: DiscountCouponTable::checkCoupon
static function checkCoupon($value, $primary, array $row, MainEntityField $field)
{
	$value = trim((string)$value);
	if ($value == '')
		return Loc::getMessage('DISCOUNT_COUPON_VALIDATOR_COUPON_EMPTY');

	$existCoupon = SaleDiscountCouponsManager::isExist($value);
	if (!empty($existCoupon))
	{
		$currentId = (int)(is_array($primary) ? $primary['ID'] : $primary);
		if ($existCoupon['MODULE'] != 'sale' || $currentId != $existCoupon['ID'])
			return Loc::getMessage('DISCOUNT_COUPON_VALIDATOR_COUPON_EXIST');
	}
	return true;
}