Август 22, 2019
Теги: Магазин
Работа со службами доставки при помощи класса "\Bitrix\Sale\Delivery\Services\Table".
Выборка всех активных служб доставки:
$result = \Bitrix\Sale\Delivery\Services\Table::getList(array(
'filter' => array('ACTIVE'=>'Y'),
));
while($delivery=$result->fetch())
{
print_r($delivery);
}
/* результат
Array
(
[ID] => 1
[CODE] =>
[PARENT_ID] => 0
[NAME] => Без доставки
[ACTIVE] => Y
[DESCRIPTION] =>
[SORT] => 100
[LOGOTIP] =>
[CONFIG] => Array
(
[MAIN] => Array
(
[CURRENCY] => RUB
[PRICE] => 0
[PERIOD] => Array
(
[FROM] => 0
[TO] => 0
[TYPE] => D
)
)
)
[CLASS_NAME] => \Bitrix\Sale\Delivery\Services\EmptyDeliveryService
[CURRENCY] => RUB
[TRACKING_PARAMS] =>
[ALLOW_EDIT_SHIPMENT] => Y
[VAT_ID] =>
)
Array
(
[ID] => 2
[CODE] => 2
[PARENT_ID] => 0
[NAME] => Доставка (из ресторана на Московском)
[ACTIVE] => Y
[DESCRIPTION] =>
[SORT] => 10
[LOGOTIP] =>
[CONFIG] => Array
(
[MAIN] => Array
(
[CURRENCY] => RUB
[PRICE] => 0
[PERIOD] => Array
(
[FROM] => 0
[TO] => 0
[TYPE] => D
)
)
)
[CLASS_NAME] => \Bitrix\Sale\Delivery\Services\Configurable
[CURRENCY] => RUB
[TRACKING_PARAMS] => Array
(
)
[ALLOW_EDIT_SHIPMENT] => Y
[VAT_ID] => 0
)
*/
Другой способ, в данном случае получаем массив названий служб доставки для определенного сайта:
$order = \Bitrix\Sale\Order::create($siteId); // можно также указать $userId, $currency
$shipmentCollection = $order->getShipmentCollection();
$shipment = $shipmentCollection->createItem();
$deliveryServicesAll = \Bitrix\Sale\Delivery\Services\Manager::getRestrictedObjectsList($shipment);
foreach($deliveryServicesAll as $deliveryService)
$values[] = $deliveryService->getName();