2namespace Sale\Handlers\Delivery\Additional\RusPost;
5use \Bitrix\Sale\Delivery\Services;
21 public static function getEnabledShippingPointsList($deliveryId, $useCache =
true)
23 $deliveryId = (int)$deliveryId;
30 if(!($deliveryService = Services\Manager::getObjectById($deliveryId)))
38 $cacheId =
"SaleHandlersDeliveryAdditionalRusPost".
41 md5(serialize($deliveryService->getConfigValues())
44 $cacheManager = \Bitrix\Main\Application::getInstance()->getManagedCache();
46 if($cacheManager->read($ttl, $cacheId))
48 return $cacheManager->get($cacheId);
52 $res = self::getEnabledShippingPointsListResult($deliveryId);
57 $cacheManager->set($cacheId,
$result);
69 public static function getEnabledShippingPointsListResult($deliveryId)
72 $deliveryId = (int)$deliveryId;
76 $result->addError(
new Error(
'deliveryId is less than zero'));
80 if(!($deliveryService = Services\Manager::getObjectById($deliveryId)))
82 $result->addError(
new Error(
'Can\t obtain delivery object'));
87 if(!($deliveryRequest = $deliveryService->getDeliveryRequestHandler()))
89 $result->addError(
new Error(
'Can\t obtain request handler'));
93 if(get_class($deliveryRequest) !=
'Sale\Handlers\Delivery\Additional\DeliveryRequests\RusPost\Handler')
95 $result->addError(
new Error(
'Can\t obtain class Sale\Handlers\Delivery\Additional\DeliveryRequests\RusPost\Handler'));
101 $res = $deliveryRequest->send(
'USER_SETTINGS', []);
103 if(
$res->isSuccess())
107 if(is_array(
$data[
'shipping-points']))
109 foreach(
$data[
'shipping-points'] as $sPoint)
111 if($sPoint[
'enabled'] == 1)
113 $points[$sPoint[
'operator-postcode']] = $sPoint;
132 public static function getSelectedShippingPoint($deliveryService)
134 if(!$deliveryService)
140 $config = $deliveryService->getConfigValues();
142 if(isset(
$config[
'MAIN'][
'SHIPPING_POINT'][
'VALUE']))