A
A
Anton2019-05-15 16:25:19
1C-Bitrix
Anton, 2019-05-15 16:25:19

How to add shipping cost to an order on api d7?

D7 - custom api checkout

How to add the shipping cost here so that it is in the order in the admin panel?
For example, $_POST['autodos'] - contains the estimated cost in rubles, for example 500.
//укажем доставку, где $_POST['DELIVERY'] - ID службы доставки, в моем случае 9 - Курьер
$shipmentCollection = $order->getShipmentCollection();
$shipment = $shipmentCollection->createItem(
       Bitrix\Sale\Delivery\Services\Manager::getObjectById($_POST['DELIVERY'])
   );
$shipmentItemCollection = $shipment->getShipmentItemCollection();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Adamos, 2019-05-15
@anton99zel

$service = \Bitrix\Sale\Delivery\Services\Manager::getById($deliveryId);
$deliveryData = [
  'DELIVERY_ID' => $service['ID'],
  'DELIVERY_NAME' => $service['NAME'],
  'ALLOW_DELIVERY' => 'Y',
  'PRICE_DELIVERY' => $deliveryPrice,
  'CUSTOM_PRICE_DELIVERY' => 'Y'
];
$shipment->setFields($deliveryData);

E
Evgeny Nikolaev, 2019-05-17
@nikolaevevge

Here is another way through setBasePriceDelivery (I think it's not D7) https://dev.1c-bitrix.ru/support/forum/forum6/topi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question