You are here

commerce_registration.tokens.inc in Commerce Registration 7

File

commerce_registration.tokens.inc
View source
<?php

/**
 * @file
 */

/**
 * Implements hook_token_info_alter().
 */
function commerce_registration_token_info_alter(&$data) {
  $data['tokens']['registration']['commerce_order'] = array(
    'name' => t('Commerce Order ID'),
    'description' => t('The Commerce order number that the registration belongs to.'),
  );
}

/**
 * Implements hook_tokens().
 */
function commerce_registration_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $items = array();
  if (!isset($data['registration'])) {
    return array();
  }
  $reg = $data['registration'];
  if ($type == 'registration') {
    foreach ($tokens as $key => $token) {
      switch ($key) {
        case "commerce_order":
          $items[$token] = $reg->order_id;
          break;
      }
    }
  }
  return $items;
}