• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/notify.php
  • Класс: BitrixSaleNotify
  • Вызов: Notify::sendOrderNew
static function sendOrderNew(InternalsEntity $entity)
{
	$result = new Result();

	if (static::isNotifyDisabled())
	{
		return $result;
	}

	if (!$entity instanceof Order)
	{
		throw new MainArgumentTypeException('entity', 'BitrixSaleOrder');
	}

	if (static::hasSentEvent($entity->getId(), static::EVENT_ORDER_NEW_SEND_EMAIL_EVENT_NAME))
	{
		return $result;
	}

	if (!$entity->isNew())
	{
		return $result;
	}

	$separator = "
"; $eventName = static::EVENT_ORDER_NEW_SEND_EMAIL_EVENT_NAME; $filter = array( "EVENT_NAME" => $eventName, 'ACTIVE' => 'Y', ); if ($entity instanceof OrderBase) { $filter['SITE_ID'] = $entity->getSiteId(); } elseif (defined('SITE_ID') && SITE_ID != '') { $filter['SITE_ID'] = SITE_ID; } $res = CEventMessage::GetList('', '', $filter); if ($eventMessage = $res->Fetch()) { if ($eventMessage['BODY_TYPE'] == 'text') { $separator = "n"; } } $basketList = ''; /** @var Basket $basket */ $basket = $entity->getBasket(); if ($basket) { $basketTextList = $basket->getListOfFormatText(); if (!empty($basketTextList)) { foreach ($basketTextList as $basketItemCode => $basketItemData) { $basketList .= $basketItemData.$separator; } } } $fields = Array( "ORDER_ID" => $entity->getField("ACCOUNT_NUMBER"), "ORDER_REAL_ID" => $entity->getField("ID"), "ORDER_ACCOUNT_NUMBER_ENCODE" => urlencode(urlencode($entity->getField("ACCOUNT_NUMBER"))), "ORDER_DATE" => $entity->getDateInsert()->toString(), "ORDER_USER" => static::getUserName($entity), "PRICE" => SaleFormatCurrency($entity->getPrice(), $entity->getCurrency()), "BCC" => MainConfigOption::get("sale", "order_email", "order@".$_SERVER["SERVER_NAME"]), "EMAIL" => static::getUserEmail($entity), "ORDER_LIST" => $basketList, "SALE_EMAIL" => MainConfigOption::get("sale", "order_email", "order@".$_SERVER["SERVER_NAME"]), "DELIVERY_PRICE" => $entity->getDeliveryPrice(), "ORDER_PUBLIC_URL" => HelpersOrder::isAllowGuestView($entity) ? HelpersOrder::getPublicLink($entity) : "" ); $send = true; foreach(GetModuleEvents("sale", static::EVENT_ON_ORDER_NEW_SEND_EMAIL, true) as $oldEvent) { if (ExecuteModuleEventEx($oldEvent, array($entity->getId(), &$eventName, &$fields)) === false) { $send = false; } } if($send) { $event = new CEvent; $event->Send($eventName, $entity->getField('LID'), $fields, "Y", "", array(),static::getOrderLanguageId($entity)); } static::addSentEvent($entity->getId(), static::EVENT_ORDER_NEW_SEND_EMAIL_EVENT_NAME); CSaleMobileOrderPush::send(static::EVENT_MOBILE_PUSH_ORDER_CREATED, array("ORDER" => static::getOrderFields($entity))); return $result; }