Как получить цены всех доставок bitrix d7?

Я получаю цену одной конкретной доставки, но не могу переделать так, чтобы получать цены всех доставок, что для этого нужно?

<?
use Bitrix\Main\Context,
    Bitrix\Currency\CurrencyManager,
    Bitrix\Sale\Order,
    Bitrix\Sale\Basket,
    Bitrix\Sale\Delivery,
    Bitrix\Sale\PaySystem;

global $USER;

Bitrix\Main\Loader::includeModule("sale");
Bitrix\Main\Loader::includeModule("catalog");

$productId = $_GET['ID']; // ID текущего товара
$siteId = Context::getCurrent()->getSite(); // ID сайта
$currencyCode = CurrencyManager::getBaseCurrency(); // Базовая валюта сайта
$deliveryId = '1';
$userCityId = '111';


// Создаём новый заказ
$order = Order::create($siteId, $USER->isAuthorized() ? $USER->GetID() : '');
$order->setPersonTypeId(1);
$order->setField('CURRENCY', $currencyCode);


// Создаём корзину с одним товаром
$basket = Basket::create($siteId);
$item = $basket->createItem('catalog', $productId);
$item->setFields(array(
    'QUANTITY' => 1,
    'CURRENCY' => $currencyCode,
    'LID' => $siteId,
    'PRODUCT_PROVIDER_CLASS' => '\CCatalogProductProvider',
));
$order->setBasket($basket);


// Устанавливаем город доставки
$orderProperties = $order->getPropertyCollection();
$orderDeliveryLocation = $orderProperties->getDeliveryLocation();
$orderDeliveryLocation->setValue($userCityId);


// Создаём одну отгрузку и устанавливаем способ доставки
$shipmentCollection = $order->getShipmentCollection();
$shipment = $shipmentCollection->createItem();

// Список доставок
$deliveryList = \Bitrix\Sale\Delivery\Services\Manager::getRestrictedList($shipment, \Bitrix\Sale\Services\Base\RestrictionManager::MODE_CLIENT);
foreach($deliveryList as $deliveryService) {
//    echo '<pre>'.print_r($deliveryService['ID']).'</pre>';
}

$service = Delivery\Services\Manager::getById($deliveryId);
$shipment->setFields(array(
    'DELIVERY_ID' => $service['ID'],
    'DELIVERY_NAME' => $service['NAME'],
));
$shipmentItemCollection = $shipment->getShipmentItemCollection();
$shipmentItem = $shipmentItemCollection->createItem($item);
$shipmentItem->setQuantity($item->getQuantity());


// Создаём оплату со способом #1
$paymentCollection = $order->getPaymentCollection();
$payment = $paymentCollection->createItem();
$paySystemService = PaySystem\Manager::getObjectById(11);
$payment->setFields(array(
    'PAY_SYSTEM_ID' => $paySystemService->getField("PAY_SYSTEM_ID"),
    'PAY_SYSTEM_NAME' => $paySystemService->getField("NAME"),
));

$deliveryPrice = $order->getDeliveryPrice();
if ($deliveryPrice === '') {
    $deliveryPrice = null;
}
$result = $deliveryPrice;

header('Content-Type: application/json; charset=utf-8');
echo json_encode(['response' => round($result, 2)]);
  • Вопрос задан
  • 405 просмотров
Решения вопроса 1
Real_Fermer
@Real_Fermer
Программист PHP
$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] => 350
                    [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] => 
    [XML_ID] => bx_1a6bf95e42d159b107a2679e2ad8a3a8
)
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы