You are here

public function ShipmentController::printShipment in Ubercart 8.4

Shows a printer-friendly version of a shipment.

Parameters

\Drupal\uc_order\OrderInterface $uc_order: The order object.

\Drupal\uc_fulfillment\ShipmentInterface $uc_shipment: The ID of shipment.

bool $print: Whether to generate a printable version.

bool $labels: Whether to include mailing labels.

Return value

array|string A render array or HTML markup in a form suitable for printing.

1 string reference to 'ShipmentController::printShipment'
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 92

Class

ShipmentController
Controller routines for shipments.

Namespace

Drupal\uc_fulfillment\Controller

Code

public function printShipment(OrderInterface $uc_order, ShipmentInterface $uc_shipment, $print = FALSE, $labels = TRUE) {
  $packing_slip = [
    '#theme' => 'uc_packing_slip',
    '#order' => $uc_order,
    '#shipment' => $uc_shipment,
    '#labels' => $labels,
    '#op' => $print ? 'print' : 'view',
  ];
  if ($print) {
    $build = [
      '#theme' => 'uc_packing_slip_page',
      '#content' => $packing_slip,
    ];
    $markup = \Drupal::service('renderer')
      ->renderPlain($build);
    $response = new Response($markup);
    $response->headers
      ->set('Content-Type', 'text/html; charset=utf-8');
    return $response;
  }
  return $packing_slip;
}