Last active
April 23, 2019 06:46
-
-
Save EscApp2/3e8c2ef5f8981b1a9b473aac3d058502 to your computer and use it in GitHub Desktop.
Получить STORE_ID (id склада) из заказа CSaleOrder bitrix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
//original http://leovy.ru/programmirovanie/cms/1s_bitriks/kak-uznat-id-sklada-iz-zapisi-zakaza-1s_bitriks | |
// bitrix ver < 16.0 | |
CModule::IncludeModule('sale'); | |
$ORDER_ID = 1; | |
$arOrder = CSaleOrder::GetByID($ORDER_ID); | |
echo $arOrder["STORE_ID"]; | |
// bitrix ver >=16.0 | |
\Bitrix\Main\Loader::includeModule('sale'); | |
$ORDER_ID = 1; | |
$order = \Bitrix\Sale\Order::load($ORDER_ID); | |
$shipmentCollection = $order->getShipmentCollection(); | |
$lastShipment = null; | |
foreach ($shipmentCollection as $shipment) { | |
if (!$shipment->isSystem()){ | |
$lastShipment = $shipment; | |
} | |
} | |
if($lastShipment){ | |
echo $lastShipment->getStoreId(); | |
}else{ | |
echo 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment