Answer the question
In order to leave comments, you need to log in
How to get shipping warehouse ID by order ID in Bitrix?
Good afternoon colleagues, share how you can get the warehouse id from the order id.
I do it like this:
$order = \Bitrix\Sale\Order::load(37);
$shipmentCollection = $order->getShipmentCollection();
foreach($shipmentCollection as $shipment) {
$shipment_id = $shipment->getId();
if ($shipment->isSystem())
continue;
$arShipments[$shipment_id] = array(
'ID' => $shipment_id,
'ACCOUNT_NUMBER' => $shipment->getField('ACCOUNT_NUMBER'),
'ORDER_ID' => $shipment->getField('ORDER_ID'),
'DELIVERY_ID' => $shipment->getField('DELIVERY_ID'),
'STOCK_ID' => $shipment->getStoreId(),
'PRICE_DELIVERY' => (float)$shipment->getField('PRICE_DELIVERY'),
'BASKET' => array(),
);
$shipmentItemCollection = $shipment->getShipmentItemCollection();
foreach($shipmentItemCollection as $item) {
$basketItem = $item->getBasketItem();
if (!$basketItem->canBuy() || $basketItem->isDelay())
continue;
$arItem = array(
'PRODUCT_ID' => $basketItem->getProductId(),
'NAME' => $basketItem->getField('NAME'),
'PRICE' => $basketItem->getPrice(),
'FINAL_PRICE' => $basketItem->getFinalPrice(),
'QUANTITY' => $basketItem->getQuantity(),
'WEIGHT' => $basketItem->getWeight(),
);
$arShipments[$shipment_id]['BASKET'][$arItem['PRODUCT_ID']] = $arItem;
}
}
Array
(
[68] => Array
(
[ID] => 68
[ACCOUNT_NUMBER] => 37/2
[ORDER_ID] => 37
[DELIVERY_ID] => 2
[STOCK_ID] => 0
[PRICE_DELIVERY] => 500
[BASKET] => Array
(
[6977] => Array
(
[PRODUCT_ID] => 6977
[NAME] => Сплит система Pioneer 07 VEKTOR
[PRICE] => 10851
[FINAL_PRICE] => 10851
[QUANTITY] => 1
[WEIGHT] => 0.00
)
)
)
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question