You are here

public function PrintButton::view in Ubercart 8.4

Returns the contents of an order pane as a store administrator.

Parameters

\Drupal\uc_order\OrderInterface $order: The order that is being viewed.

string $view_mode: The view mode that is being used to render the order.

Return value

array A render array showing order data.

Overrides OrderPanePluginInterface::view

File

uc_order/src/Plugin/Ubercart/OrderPane/PrintButton.php, line 30

Class

PrintButton
Button to open a printable invoice.

Namespace

Drupal\uc_order\Plugin\Ubercart\OrderPane

Code

public function view(OrderInterface $order, $view_mode) {
  if ($view_mode == 'customer' && $order
    ->access('invoice')) {
    $build = [
      '#type' => 'link',
      '#title' => $this
        ->t('Click to open a window with a printable invoice.'),
      '#url' => Url::fromRoute('uc_order.user_invoice_print', [
        'user' => $order
          ->getOwnerId(),
        'uc_order' => $order
          ->id(),
      ], [
        'attributes' => [
          'onclick' => "window.open(this.href, '" . $this
            ->t('Invoice') . "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=480,left=50,top=50'); return false;",
        ],
      ]),
    ];
    return $build;
  }
}