• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/compatible/eventcompatibility.php
  • Класс: BitrixSaleCompatibleEventCompatibility
  • Вызов: EventCompatibility::onSaleCancelOrder
static function onSaleCancelOrder(MainEvent $event)
{
	if (static::$disableEvent === true)
	{
		return new MainEventResult( MainEventResult::SUCCESS, null, 'sale');
	}

	$parameters = $event->getParameters();

	/** @var SaleOrder $order */
	$order = $parameters['ENTITY'];
	if (!$order instanceof SaleOrder)
	{
		return new MainEventResult(
			MainEventResult::ERROR,
			new SaleResultError(MainLocalizationLoc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_DELETE_WRONG_ORDER'),
			'sale'
		);
	}

	$canceled = $order->getField('CANCELED');
	$id = $order->getId();
	$description = $order->getField('REASON_CANCELED');

	static::setDisableEvent(true);
	foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_ORDER_CANCELED, true) as $oldEvent)
	{
		ExecuteModuleEventEx($oldEvent, array($id, $canceled, $description));
		$order->setField('REASON_CANCELED', $description);
	}
	static::setDisableEvent(false);

	return new MainEventResult( MainEventResult::SUCCESS, null, 'sale');
}