You are here

function commerce_invoice_receipt_theme in Commerce Invoice Receipt 7

Same name and namespace in other branches
  1. 7.2 commerce_invoice_receipt.module \commerce_invoice_receipt_theme()

Implements hook_theme().

File

./commerce_invoice_receipt.module, line 206
Provides a printable invoice receipt along with HTML mailing rules.

Code

function commerce_invoice_receipt_theme() {

  // Get current default theme
  $default_theme_path = drupal_get_path('theme', variable_get('theme_default', NULL));
  $default_template_path = drupal_get_path('module', 'commerce_invoice_receipt') . '/theme';

  // Check if the template has been copied in the front end theme.
  //
  // A manual check is necessary because otherwise Drupal will not find the
  // template override in the front end theme, when the site uses an admin theme
  // (e.g. when an administrator tries to see printable invoice from the back
  // end).
  //
  // This way the template will always be fetched from the front end theme if
  // there is one.
  //
  // Also, this way the template file can be located anywhere in the front end
  // theme (root, templates/, invoice/, or any other subfolder).
  $files = file_scan_directory($default_theme_path, '/commerce-order-invoice-view.tpl.php$/');
  if (count($files)) {
    $default_template_path = $default_theme_path;
  }
  return array(
    'commerce_order_invoice_view' => array(
      'variables' => array(
        'info' => NULL,
        'order' => NULL,
      ),
      'path' => $default_template_path,
      'template' => 'commerce-order-invoice-view',
    ),
  );
}