• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/controller/taxidelivery.php
  • Класс: BitrixSaleControllerTaxiDelivery
  • Вызов: TaxiDelivery::getShipmentById
private function getShipmentById(int $shipmentId)
{
	/**
	 * Get shipment object
	 */
	$shipmentRecord = ShipmentTable::getById($shipmentId)->fetch();
	if (!$shipmentRecord)
	{
		$this->addError(new Error('shipment_not_found'));
		return null;
	}

	/** @var Order $order */
	$order = Order::load($shipmentRecord['ORDER_ID']);
	if (!$order)
	{
		$this->addError(new Error('order_not_found'));
		return null;
	}

	$shipment = null;
	$shipmentCollection = $order->getShipmentCollection()->getNotSystemItems();
	/** @var Shipment $shipment */
	foreach ($shipmentCollection as $shipment)
	{
		if ($shipment->getId() == $shipmentId)
		{
			break;
		}
	}

	if (!$shipment)
	{
		$this->addError(new Error('shipment_not_found'));
		return null;
	}

	if (!$shipment->getDelivery() instanceof ITaxiDeliveryService)
	{
		$this->addError(new Error(Loc::getMessage('CONTROLLER_ERROR_CODE_NOT_OF_TAXI_TYPE')));
		return null;
	}

	return $shipment;
}