You are here

public function OrderRenderer::render in Commerce Core 8.2

File

modules/order/src/EntityPrint/OrderRenderer.php, line 72

Class

OrderRenderer
Provides a custom entity_print renderer for orders.

Namespace

Drupal\commerce_order\EntityPrint

Code

public function render(array $orders) {
  $profile_view_builder = $this->entityTypeManager
    ->getViewBuilder('profile');
  $build = [];
  foreach ($orders as $order) {
    assert($order instanceof OrderInterface);
    $order_build = [
      '#theme' => 'commerce_order_receipt__entity_print',
      '#order_entity' => $order,
      '#totals' => $this->orderTotalSummary
        ->buildTotals($order),
    ];
    if ($billing_profile = $order
      ->getBillingProfile()) {
      $order_build['#billing_information'] = $profile_view_builder
        ->view($billing_profile);
    }
    $build[] = $order_build;
  }
  return $build;
}