5use Bitrix\Main\Entity\EventResult;
36 if(\CModule::IncludeModule(
'catalog'))
39 if ($productProvider = \CSaleBasket::GetProductProvider(array(
40 "MODULE" =>
"catalog",
41 "PRODUCT_PROVIDER_CLASS" =>
"CCatalogProductProvider"))
45 $bTmpUserCreated =
false;
46 if (!\CCatalog::IsUserExists())
48 $bTmpUserCreated =
true;
58 $result = $productProvider::GetProductData(array(
59 "PRODUCT_ID" => $productId,
61 "QUANTITY" => $quantity,
65 $result[
"MODULE"] =
"catalog";
66 $result[
"PRODUCT_PROVIDER_CLASS"] =
"CCatalogProductProvider";
67 $dbIblockElement = \CIBlockElement::GetList(array(), array(
"ID" => $productId),
false,
false, array(
'XML_ID',
'IBLOCK_EXTERNAL_ID'));
69 if($IblockElement = $dbIblockElement->Fetch())
71 if($IblockElement[
"XML_ID"] <>
'')
72 $result[
"PRODUCT_XML_ID"] = $IblockElement[
"XML_ID"];
74 if($IblockElement[
"IBLOCK_EXTERNAL_ID"] <>
'')
75 $result[
"CATALOG_XML_ID"] = $IblockElement[
"IBLOCK_EXTERNAL_ID"];
91 throw new \Bitrix\Main\SystemException(
"Can't include module \"Catalog\"!");
103 $dbResultList = \CSalePersonType::GetList(
112 $arPersonTypes = array();
113 while ($arPT = $dbResultList->Fetch())
114 $arPersonTypes[$arPT[
'ID']] = $arPT[
'NAME'];
116 return $arPersonTypes;
125 $arDeliveryFilter = array(
130 $dbDeliveryList = \CSaleDelivery::GetList(
131 array(
"NAME" =>
"ASC"),
138 $arDeliveryList=array();
139 while ($arDelivery = $dbDeliveryList->Fetch())
140 $arDeliveryList[$arDelivery[
"ID"]] = $arDelivery[
"NAME"];
142 return $arDeliveryList;
151 if(intval($personTypeId) <= 0)
154 $res = OrderPropsTable::getList(array(
155 'filter' => array(
'=PERSON_TYPE_ID' => $personTypeId),
156 'order' => array(
'SORT' =>
'ASC',
'NAME' =>
'ASC'),
157 'select' => array(
'ID',
'CODE',
'NAME')
160 return $res->fetchAll();
187 static $arPaySystems = array();
189 if(!isset($arPaySystems[$personTypeId]))
191 $arPaySystems[$personTypeId] = array();
192 $dbResultList = \CSalePaySystem::GetList(
193 array(
"NAME" =>
"ASC"),
196 "PSA_PERSON_TYPE_ID" => $personTypeId,
203 while($arPS = $dbResultList->Fetch())
204 $arPaySystems[$personTypeId][$arPS[
'ID']] = $arPS[
'NAME'];
207 $result =
'<select name="'.$selectName.
'">'.
208 '<option value="">'.Loc::getMessage(
"SALE_EBAY_HLP_NOT_USE").
'</option>';
210 foreach ($arPaySystems[$personTypeId] as $psId => $psName)
212 $result.=
'<option value="'.
214 ($psIdValue == $psId ?
' selected ':
'').
'>'.
215 htmlspecialcharsbx($psName).
219 $result .=
'</select>';
231 public static function getSelectHtml($name, array $data, $selected =
"", $bShowNotUse =
true)
233 if(!is_array($data) || empty($data))
236 $result =
'<select name="'.htmlspecialcharsbx($name).
'">';
239 $result .=
'<option value="">'.GetMessage(
"SALE_YM_NOT_USE").
'</option>';
241 foreach($data as $value => $title)
242 $result .=
'<option value="'.htmlspecialcharsbx($value).
'"'.($selected == $value ?
" selected" :
"").
'>'.htmlspecialcharsbx($title).
'</option>';
244 $result .=
'</select>';
255 $psId = intval($params[
"PAY_SYSTEM"]);
259 $arPropFilter = array(
260 "PERSON_TYPE_ID" => $params[
"PERSON_TYPE"],
266 $arPropFilter[
"RELATED"][
"PAYSYSTEM_ID"] = $psId;
267 $arPropFilter[
"RELATED"][
"TYPE"] =
"WITH_NOT_RELATED";
270 if ($params[
"DELIVERY"] <>
'')
272 $arPropFilter[
"RELATED"][
"DELIVERY_ID"] = $params[
"DELIVERY"];
273 $arPropFilter[
"RELATED"][
"TYPE"] =
"WITH_NOT_RELATED";
276 $dbOrderProps = \CSaleOrderProps::GetList(
284 while ($arOrderProps = $dbOrderProps->Fetch())
286 foreach (self::getOrderProps() as $prop)
288 if ($arOrderProps[
"CODE"] == $params[
"ORDER_PROPS_MAP"][$prop] && isset($params[$prop]))
289 $result[$arOrderProps[
"ID"]] = $params[$prop];
315 'select' => array(
"LANGUAGE_ID"),
318 if ($site = $dbRes->fetch())
319 $langId = $site[
"LANGUAGE_ID"];
321 throw new SystemException(
"Site with id: \"" . $siteId .
"\" not found!");
323 $dbRes = StatusLangTable::getList(array(
326 'STATUS.TYPE' =>
'O',
329 "STATUS.SORT" =>
"ASC",
333 "ID" =>
"STATUS.ID",
"NAME",
337 while ($row = $dbRes->fetch())
338 $result[$row[
'ID']] =
Loc::getMessage(
"SALE_EBAY_HLP_STATUS") .
" " . $row[
'NAME'] .
' [' . $row[
'ID'] .
']';
352 $catProps = self::getPropertiesList($iblockId, $bitrixCategoryId);
355 ' <select name="' . $selectName .
'">
356 <option value=""></option>
357 <option value="">------------------</option>
358 <option value="">' .
Loc::getMessage(
"SALE_EBAY_HLP_CATEGORY_PROPS") .
'</option>
359 <option value="">------------------</option>';
361 foreach ($catProps as $propId => $prop)
362 $resultHtml .=
'<option value="' . $propId .
'"' . ($value == $propId ?
' selected' :
'') .
'>' . htmlspecialcharsbx($prop[
"NAME"]) .
'</option>';
364 $arOffers = \CCatalogSKU::GetInfoByProductIBlock($iblockId);
367 $catProps2 = self::getPropertiesList($arOffers[
"IBLOCK_ID"], $bitrixCategoryId);
370 <option value="">------------------</option>
371 <option value="">' .
Loc::getMessage(
"SALE_EBAY_HLP_OFFERS_PROPS") .
'</option>
372 <option value="">------------------</option>
375 foreach ($catProps2 as $propId => $prop)
376 $resultHtml .=
'<option value="' . $propId .
'"' . ($value == $propId ?
' selected' :
'') .
'>' . htmlspecialcharsbx($prop[
"NAME"]) .
'</option>';
379 $resultHtml .=
' </select>';
391 $result = \CIBlockSectionPropertyLink::GetArray($iblockId, $sectionId);
393 $rsProps = \CIBlockProperty::GetList(array(
397 "IBLOCK_ID" => $iblockId,
398 "CHECK_PERMISSIONS" =>
"N",
402 while ($arProp = $rsProps->Fetch())
403 if (isset($result[$arProp[
"ID"]]))
404 $result[$arProp[
"ID"]][
"NAME"] = $arProp[
"NAME"];
410 public function notifyNewOrder($newOrderId, $siteId, $buyerEmail =
"", $buyerFio =
"")
412 if ($newOrderId ==
'')
421 $baseLangCurrency = \CSaleLang::GetLangCurrency($siteId);
422 $orderNew = \CSaleOrder::GetByID($newOrderId);
423 $orderNew[
"BASKET_ITEMS"] = array();
425 $dbBasketTmp = \CSaleBasket::GetList(
426 array(
"SET_PARENT_ID" =>
"DESC",
"TYPE" =>
"DESC",
"NAME" =>
"ASC"),
427 array(
"ORDER_ID" => $newOrderId),
431 "ID",
"PRICE",
"QUANTITY",
"NAME",
435 while ($arBasketTmp = $dbBasketTmp->GetNext())
436 $orderNew[
"BASKET_ITEMS"][] = $arBasketTmp;
438 $orderNew[
"BASKET_ITEMS"] = getMeasures($orderNew[
"BASKET_ITEMS"]);
440 foreach ($orderNew[
"BASKET_ITEMS"] as $val)
442 if (\CSaleBasketHelper::isSetItem($val))
445 $measure = (isset($val[
"MEASURE_TEXT"])) ? $val[
"MEASURE_TEXT"] : GetMessage(
"SALE_YMH_SHT");
446 $strOrderList .= $val[
"NAME"] .
" - " . $val[
"QUANTITY"] .
" " . $measure .
" x " . SaleFormatCurrency($val[
"PRICE"], $baseLangCurrency);
447 $strOrderList .=
"</br>";
452 "ORDER_ID" => $orderNew[
"ACCOUNT_NUMBER"],
453 "ORDER_DATE" =>
Date($DB->DateFormatToPHP(\CLang::GetDateFormat(
"SHORT", $siteId))),
454 "ORDER_USER" => $buyerFio,
455 "PRICE" => SaleFormatCurrency($orderNew[
"PRICE"], $baseLangCurrency),
456 "BCC" => \COption::GetOptionString(
"sale",
"order_email",
"order@" . $_SERVER[
'SERVER_NAME']),
457 "EMAIL_TO" => array(
"PAYER_NAME" => $buyerFio,
"USER_EMAIL" => $buyerEmail),
458 "ORDER_LIST" => $strOrderList,
459 "SALE_EMAIL" => \COption::GetOptionString(
"sale",
"order_email",
"order@" . $_SERVER[
'SERVER_NAME']),
460 "DELIVERY_PRICE" => $orderNew[
"DELIVERY_PRICE"],
463 $eventName =
"SALE_NEW_ORDER";
467 foreach (GetModuleEvents(
"sale",
"OnOrderNewSendEmail",
true) as $arEvent)
468 if (ExecuteModuleEventEx($arEvent, array($newOrderId, &$eventName, &$arFields)) ===
false)
471 $emailSendRes =
false;
475 $event = new \CEvent;
476 $emailSendRes = $event->Send($eventName, $siteId, $arFields,
"N");
479 $pushSendResult = \CSaleMobileOrderPush::send(
"ORDER_CREATED", array(
"ORDER" => $orderNew));
481 return $emailSendRes && $pushSendResult;
487 $data = $event->getParameter(
'fields');
489 if (!isset($data[
"TRACKING_NUMBER"]) && !isset($data[
"DELIVERY_NAME"]))
492 $primary = $event->getParameter(
'id');
494 $dbRes = OrderTable::getList(array(
497 'SITE_ID' =>
'ORDER.LID',
498 'TRADING_PLATFORM_CODE' =>
'TRADING_PLATFORM.CODE',
499 'TRADING_PLATFORM_CLASS' =>
'TRADING_PLATFORM.CLASS',
500 'DELIVERY_NAME' =>
'SHIPMENT.DELIVERY.NAME',
501 'DELIVERY_ID' =>
'SHIPMENT.DELIVERY_ID',
502 'TRACKING_NUMBER' =>
'SHIPMENT.TRACKING_NUMBER',
505 '=SHIPMENT.ID' => $primary[
'ID'],
509 'data_type' =>
'Bitrix\Sale\Internals\ShipmentTable',
510 'reference' => array(
511 '=this.ORDER_ID' =>
'ref.ORDER_ID',
517 if ($platformOrder = $dbRes->fetch())
519 if (class_exists($platformOrder[
'TRADING_PLATFORM_CLASS']) && is_subclass_of($platformOrder[
'TRADING_PLATFORM_CLASS'],
'\Bitrix\Sale\TradingPlatform\Platform'))
521 if ($platform = call_user_func($platformOrder[
'TRADING_PLATFORM_CLASS'] .
'::getInstance'))
523 $result = $platform->onAfterUpdateShipment(
528 'TRACKING_NUMBER' => isset($data[
"TRACKING_NUMBER"]) ? $data[
"TRACKING_NUMBER"] : $platformOrder[
"TRACKING_NUMBER"],
529 'DELIVERY_NAME' => isset($data[
"DELIVERY_NAME"]) ? $data[
"DELIVERY_NAME"] : $platformOrder[
"DELIVERY_NAME"],
530 'DELIVERY_ID' => isset($data[
"DELIVERY_ID"]) ? $data[
"DELIVERY_ID"] : $platformOrder[
"DELIVERY_ID"],
547 if (!isset(self::$arIBlockIDs))
549 self::$arIBlockIDs = array();
552 $rsCatalogs = \CCatalog::GetList(
554 array(
'!PRODUCT_IBLOCK_ID' => 0),
557 array(
'IBLOCK_ID',
'PRODUCT_IBLOCK_ID',
'NAME')
559 while ($arCatalog = $rsCatalogs->Fetch())
561 $arCatalog[
'PRODUCT_IBLOCK_ID'] = intval($arCatalog[
'PRODUCT_IBLOCK_ID']);
562 if (0 < $arCatalog[
'PRODUCT_IBLOCK_ID'])
563 self::$arIBlockIDs[$arCatalog[
'PRODUCT_IBLOCK_ID']] = array(
564 "IBLOCK_ID" => $arCatalog[
'PRODUCT_IBLOCK_ID'],
571 $arCatalog[
'IBLOCK_ID'] = intval($arCatalog[
'IBLOCK_ID']);
572 if (0 < $arCatalog[
'IBLOCK_ID'])
573 self::$arIBlockIDs[$arCatalog[
'IBLOCK_ID']] = array(
574 "IBLOCK_ID" => $arCatalog[
'IBLOCK_ID'],
575 "NAME" => $arCatalog[
'NAME'],
581 $rsCatalogs = \CCatalog::GetList(
583 array(
'PRODUCT_IBLOCK_ID' => 0),
586 array(
'IBLOCK_ID',
'NAME')
588 while ($arCatalog = $rsCatalogs->Fetch())
590 $arCatalog[
'IBLOCK_ID'] = intval($arCatalog[
'IBLOCK_ID']);
591 if (0 < $arCatalog[
'IBLOCK_ID'])
592 self::$arIBlockIDs[$arCatalog[
'IBLOCK_ID']] = array(
593 "IBLOCK_ID" => $arCatalog[
'IBLOCK_ID'],
594 "NAME" => $arCatalog[
'NAME'],
598 if (empty(self::$arIBlockIDs))
599 self::$arIBlockIDs[-1] =
true;
602 return self::$arIBlockIDs;
static includeModule($moduleName)
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)
static getList(array $parameters=array())