Skip to content

Instantly share code, notes, and snippets.

@EscApp2
Last active April 23, 2019 06:46
Show Gist options
  • Save EscApp2/3e8c2ef5f8981b1a9b473aac3d058502 to your computer and use it in GitHub Desktop.
Save EscApp2/3e8c2ef5f8981b1a9b473aac3d058502 to your computer and use it in GitHub Desktop.
Получить STORE_ID (id склада) из заказа CSaleOrder bitrix
<?
//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