• Модуль: salescenter
  • Путь к файлу: ~/bitrix/modules/salescenter/lib/controller/deliveryselector.php
  • Класс: BitrixSalesCenterControllerDeliverySelector
  • Вызов: DeliverySelector::getShipmentDataAction
public function getShipmentDataAction(int $id)
{
	if (!Loader::includeModule('sale'))
	{
		$this->addError(new Error('sale module is not installed'));
		return null;
	}

	$shipment = ShipmentRepository::getInstance()->getById($id);
	if (!$shipment)
	{
		$this->addError(new Error('shipment not found'));
		return null;
	}

	$parentDeliveryService = null;
	$extraServiceDisplayValues = [];

	$deliveryService = $shipment->getDelivery();
	if ($deliveryService)
	{
		$deliveryServiceName = $deliveryService->getName();
		$deliveryServiceLogo = $deliveryService->getLogotipPath();

		$parentDeliveryService = $deliveryService->getParentService();

		$extraServiceInstances = $shipment->getExtraServicesObjects();
		foreach ($extraServiceInstances as $extraServiceInstance)
		{
			$extraServiceDisplayValues[] = [
				'name' => $extraServiceInstance->getName(),
				'value' => $extraServiceInstance->getDisplayValue(),
			];
		}
	}

	$deliveryRequest = null;
	$deliveryRequestId = DeliveryRequestsManager::getRequestIdByShipmentId($shipment->getId());
	if ($deliveryRequestId)
	{
		$deliveryRequest = DeliveryRequestsRequestTable::getRowById($deliveryRequestId);
	}

	return [
		'shipment' => [
			'deliveryService' => [
				'name' => $deliveryServiceName ?? $shipment->getDeliveryName(),
				'logo' => $deliveryServiceLogo ?? null,
				'parent' => $parentDeliveryService
					? [
						'name' => $parentDeliveryService->getName(),
						'logo' => $parentDeliveryService->getLogotipPath(),
					]
					: null,
			],
			'priceDelivery' => $shipment->getField('PRICE_DELIVERY'),
			'basePriceDelivery' => $shipment->getField('BASE_PRICE_DELIVERY'),
			'currency' => $shipment->getCurrency(),
			'extraServices' => $extraServiceDisplayValues,
			'requestProperties' =>
				(
					isset($deliveryRequest['EXTERNAL_PROPERTIES'])
					&& is_array($deliveryRequest['EXTERNAL_PROPERTIES'])
				)
					? array_map(
						static function (array $property)
						{
							return [
								'name' => $property['NAME'] ?? null,
								'value' => $property['VALUE'] ?? null,
								'tags' => $property['TAGS'] ?? null,
							];
						},
						$deliveryRequest['EXTERNAL_PROPERTIES']
					)
					: []
			,
		],
		'canUserPerformCalls' => (
			Loader::includeModule('voximplant')
			&& Helper::canCurrentUserPerformCalls()
		),
	];
}