• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/invoice/internals/invoicediscount.php
  • Класс: Bitrix\Crm\Invoice\Internals\InvoiceCouponsTable
  • Вызов: InvoiceCouponsTable::applyOrder
static function applyOrder($coupons, $order)
{
	$order = (int)$order;
	if ($order <= 0 || empty($coupons))
		return;
	if (!is_array($coupons))
		$coupons = array($coupons);
	Main\Type\Collection::normalizeArrayValuesByInt($coupons, true);
	if (empty($coupons))
		return;
	$conn = Main\Application::getConnection();
	$helper = $conn->getSqlHelper();
	$conn->queryExecute(
		'update '.$helper->quote(self::getTableName()).
		' set '.$helper->quote('ORDER_ID').' = '.$order.' where '.
		$helper->quote('ID').' in ('.implode(',', $coupons).') and '.
		$helper->quote('ORDER_ID').' = 0'
	);
}