You are here

function commerce_email_tokens in Commerce Email 7.2

Same name and namespace in other branches
  1. 7 commerce_email.tokens.inc \commerce_email_tokens()

Implements hook_tokens().

File

./commerce_email.tokens.inc, line 21
Defines additional tokens for order email.

Code

function commerce_email_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $url_options = array(
    'absolute' => TRUE,
  );
  if (isset($options['language'])) {
    $url_options['language'] = $options['language'];
    $language_code = $options['language']->language;
  }
  else {
    $language_code = NULL;
  }
  $sanitize = !empty($options['sanitize']);
  $replacements = array();
  if ($type == 'commerce-order' && !empty($data['commerce-order'])) {
    $order = $data['commerce-order'];
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'commerce-email-order-items':
          $order_items = commerce_email_order_items($order);
          $replacements[$original] = $order_items;
          break;
      }
    }
  }
  return $replacements;
}