public function ShipmentController::viewShipment in Ubercart 8.4
Displays shipment details.
Parameters
\Drupal\uc_order\OrderInterface $uc_order: The order object.
\Drupal\uc_fulfillment\ShipmentInterface $uc_shipment: The shipment.
Return value
array A render array.
1 string reference to 'ShipmentController::viewShipment'
- uc_fulfillment.routing.yml in shipping/
uc_fulfillment/ uc_fulfillment.routing.yml - shipping/uc_fulfillment/uc_fulfillment.routing.yml
File
- shipping/
uc_fulfillment/ src/ Controller/ ShipmentController.php, line 225
Class
- ShipmentController
- Controller routines for shipments.
Namespace
Drupal\uc_fulfillment\ControllerCode
public function viewShipment(OrderInterface $uc_order, ShipmentInterface $uc_shipment) {
// Origin address.
$build['pickup_address'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'order-pane',
'pos-left',
],
],
];
$build['pickup_address']['title'] = [
'#type' => 'container',
'#markup' => $this
->t('Pickup Address:'),
'#attributes' => [
'class' => [
'order-pane-title',
],
],
];
$build['pickup_address']['address'] = [
'#type' => 'container',
'#markup' => $uc_shipment
->getOrigin(),
];
// Destination address.
$build['delivery_address'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'order-pane',
'pos-left',
],
],
];
$build['delivery_address']['title'] = [
'#type' => 'container',
'#markup' => $this
->t('Delivery Address:'),
'#attributes' => [
'class' => [
'order-pane-title',
],
],
];
$build['delivery_address']['address'] = [
'#type' => 'container',
'#markup' => $uc_shipment
->getDestination(),
];
// Fulfillment schedule.
$rows = [];
$rows[] = [
$this
->t('Ship date:'),
\Drupal::service('date.formatter')
->format($uc_shipment
->getShipDate(), 'uc_store'),
];
$rows[] = [
$this
->t('Expected delivery:'),
\Drupal::service('date.formatter')
->format($uc_shipment
->getExpectedDelivery(), 'uc_store'),
];
$build['schedule'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'order-pane',
'abs-left',
],
],
];
$build['schedule']['title'] = [
'#type' => 'container',
'#markup' => $this
->t('Schedule:'),
'#attributes' => [
'class' => [
'order-pane-title',
],
],
];
$build['schedule']['table'] = [
'#theme' => 'table',
'#rows' => $rows,
'#attributes' => [
'style' => 'width: auto',
],
];
// Shipment details.
$rows = [];
$rows[] = [
$this
->t('Carrier:'),
[
'data' => [
'#plain_text' => $uc_shipment
->getCarrier(),
],
],
];
if ($uc_shipment
->getTransactionId()) {
$rows[] = [
$this
->t('Transaction ID:'),
[
'data' => [
'#plain_text' => $uc_shipment
->getTransactionId(),
],
],
];
}
if ($uc_shipment
->getTrackingNumber()) {
$rows[] = [
$this
->t('Tracking number:'),
[
'data' => [
'#plain_text' => $uc_shipment
->getTrackingNumber(),
],
],
];
}
$methods = \Drupal::moduleHandler()
->invokeAll('uc_fulfillment_method');
if (isset($methods[$uc_shipment
->getShippingMethod()]['quote']['accessorials'][$uc_shipment
->getAccessorials()])) {
$rows[] = [
$this
->t('Services:'),
$methods[$uc_shipment
->getShippingMethod()]['quote']['accessorials'][$uc_shipment
->getAccessorials()],
];
}
else {
$rows[] = [
$this
->t('Services:'),
$uc_shipment
->getAccessorials(),
];
}
$rows[] = [
$this
->t('Cost:'),
[
'data' => [
'#theme' => 'uc_price',
'#price' => $uc_shipment
->getCost(),
],
],
];
$build['details'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'order-pane',
'abs-left',
],
],
];
$build['details']['title'] = [
'#type' => 'container',
'#markup' => $this
->t('Shipment Details:'),
'#attributes' => [
'class' => [
'order-pane-title',
],
],
];
$build['details']['table'] = [
'#theme' => 'table',
'#rows' => $rows,
'#attributes' => [
'style' => 'width:auto',
],
];
// Packages.
foreach ($uc_shipment
->getPackages() as $package) {
$build['packages'][] = $this
->viewPackage($package);
}
return $build;
}