You are here

function commerce_invoice_pdf_entity_view in Commerce Invoice 7.2

Implements hook_entity_view().

File

modules/pdf/commerce_invoice_pdf.module, line 51
The Commerce Invoice PDF module.

Code

function commerce_invoice_pdf_entity_view($entity, $type, $view_mode, $langcode) {

  // Add "Download PDF" link to the bottom of invoice page.
  if ($type == 'commerce_invoice' && $view_mode == 'full') {
    $entity->content['pdf_link'] = [
      '#theme' => 'link',
      '#weight' => 50,
      '#text' => t('Download PDF'),
      '#path' => 'invoices/' . $entity->invoice_id . '/pdf',
      '#options' => [
        'query' => [
          'download' => 1,
        ],
        'html' => FALSE,
        'attributes' => [],
      ],
    ];
  }
}