You are here

function commerce_registration_tokens in Commerce Registration 7.3

Same name and namespace in other branches
  1. 7 commerce_registration.tokens.inc \commerce_registration_tokens()
  2. 7.2 commerce_registration.tokens.inc \commerce_registration_tokens()

Implements hook_tokens().

File

./commerce_registration.tokens.inc, line 26
Add token for Commerce Order to Registrations.

Code

function commerce_registration_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $items = array();
  if (!isset($data['registration'])) {
    return array();
  }
  switch ($type) {
    case 'registration':
      $reg = $data['registration'];
      foreach ($tokens as $key => $token) {
        switch ($key) {
          case "commerce_line_item_id":
            $items[$token] = $reg->lineitem_id;
            break;
          case "commerce_line_item":
            $line_item = commerce_line_item_load($reg->lineitem_id);
            $items[$token] = $line_item;
            break;
        }
      }
      break;
  }
  return $items;
}