- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/compatible/eventcompatibility.php
- Класс: BitrixSaleCompatibleEventCompatibility
- Вызов: EventCompatibility::onOrderNewSendEmail
static function onOrderNewSendEmail(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'];
$isNew = $parameters['IS_NEW'];
if (!$order instanceof SaleOrder)
{
return new MainEventResult(
MainEventResult::ERROR,
new SaleResultError(MainLocalizationLoc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_ORDER'), 'SALE_EVENT_COMPATIBILITY_ORDER_NEW_SEND_EMAIL_WRONG_ORDER'),
'sale'
);
}
$id = $order->getId();
if (!$isNew)
{
return new MainEventResult( MainEventResult::SUCCESS, null, 'sale');
}
$registry = SaleRegistry::getInstance($order::getRegistryType());
/** @var SaleNotify $notifyClassName */
$notifyClassName = $registry->getNotifyClassName();
$notifyClassName::sendOrderNew($order);
$GLOBALS['SALE_NEW_ORDER_SEND'][$id] = true;
return new MainEventResult( MainEventResult::SUCCESS, null, 'sale');
}