You are here

function commerce_invoice_receipt_theme in Commerce Invoice Receipt 7.2

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

Implements hook_theme().

File

./commerce_invoice_receipt.module, line 141
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-invoice-receipt.tpl.php$/');
  if (count($files)) {
    $first = reset($files);
    $default_template_path = dirname($first->uri);
  }
  return array(
    'commerce_invoice_receipt' => array(
      'variables' => array(
        'info' => NULL,
        'order' => NULL,
      ),
      'path' => $default_template_path,
      'template' => 'commerce-invoice-receipt',
    ),
  );
}