2023-10-18 16:16:35 +03:00
|
|
|
<?php
|
|
|
|
|
2024-04-29 11:44:31 +03:00
|
|
|
/**
|
|
|
|
* @category RetailCRM
|
|
|
|
* @package RetailCRM\Service
|
|
|
|
* @author RetailCRM <integration@retailcrm.ru>
|
|
|
|
* @license MIT
|
|
|
|
* @link http://retailcrm.ru
|
|
|
|
* @see http://retailcrm.ru/docs
|
|
|
|
*/
|
|
|
|
|
2023-10-18 16:16:35 +03:00
|
|
|
use Bitrix\Sale\Order;
|
|
|
|
use Bitrix\Main\Context;
|
|
|
|
use Bitrix\Catalog\StoreTable;
|
|
|
|
|
2024-04-29 11:44:31 +03:00
|
|
|
/**
|
|
|
|
* Class BitrixOrderService
|
|
|
|
*
|
|
|
|
* @category RetailCRM
|
|
|
|
* @package RetailCRM\Service
|
|
|
|
*/
|
2023-10-18 16:16:35 +03:00
|
|
|
class BitrixOrderService
|
|
|
|
{
|
|
|
|
public static function getCountryList()
|
|
|
|
{
|
|
|
|
$server = Context::getCurrent()->getServer()->getDocumentRoot();
|
|
|
|
$countryList = [];
|
|
|
|
|
|
|
|
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
|
|
|
|
$countryFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
|
|
|
|
|
|
|
|
foreach ($countryFile->country as $country) {
|
|
|
|
$countryList[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $countryList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getPickupPointAddress($arOrder)
|
|
|
|
{
|
|
|
|
$address = '';
|
|
|
|
$orderInfo = Order::load($arOrder['ID']);
|
|
|
|
|
|
|
|
foreach ($orderInfo->getShipmentCollection() as $store) {
|
|
|
|
$storeId = $store->getStoreId();
|
|
|
|
|
|
|
|
if ($storeId) {
|
|
|
|
$arStore = StoreTable::getRow([
|
|
|
|
'filter' => [
|
|
|
|
'ID' => $storeId,
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (!empty($arStore['ADDRESS'])) {
|
|
|
|
$address = GetMessage('PICKUP_POINT') . $arStore['ADDRESS'];
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $address;
|
|
|
|
}
|
|
|
|
}
|