You are here

function commerce_email_tokens in Commerce Email 7

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

Implements hook_tokens().

File

./commerce_email.tokens.inc, line 40
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-email' && !empty($data['commerce-order'])) {
    $order = $data['commerce-order'];
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'order-items':
          $replacements[$original] = $order->order_items;
          break;
        case 'customer-name':
          $replacements[$original] = $order->customer_name;
          break;
      }
    }
  }
  return $replacements;
}