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

	if (static::$disableMailSend === 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_CANCEL_SEND_EMAIL_WRONG_ORDER'),
			'sale'
		);
	}

	$id = $order->getId();
	$value = $order->getField('CANCELED');

	if ($value == "Y")
	{
		$registry = SaleRegistry::getInstance($order::getRegistryType());

		/** @var SaleNotify $notifyClassName */
		$notifyClassName = $registry->getNotifyClassName();
		$notifyClassName::sendOrderCancel($order);

		if (MainLoader::includeModule("statistic"))
		{
			CStatEvent::AddByEvents("eStore", "order_cancel", $id, "", $order->getField("STAT_GID"));
		}

		$GLOBALS['SALE_ORDER_CANCEL_SEND'][$id] = true;

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