commerce_registration.tokens.inc in Commerce Registration 7.3
Same filename and directory in other branches
Add token for Commerce Order to Registrations.
File
commerce_registration.tokens.incView source
<?php
/**
* @file
* Add token for Commerce Order to Registrations.
*/
/**
* Implements hook_token_info().
*/
function commerce_registration_token_info() {
$data['tokens']['registration']['commerce_line_item_id'] = array(
'name' => t('Commerce Line Item ID'),
'description' => t('The Commerce line item ID to which the registration belongs.'),
);
$data['tokens']['registration']['commerce_line_item'] = array(
'name' => t('Commerce Line Item ID'),
'description' => t('The Commerce line item to which the registration belongs.'),
'type' => 'commerce-line-item',
);
return $data;
}
/**
* Implements hook_tokens().
*/
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;
}
Functions
Name![]() |
Description |
---|---|
commerce_registration_tokens | Implements hook_tokens(). |
commerce_registration_token_info | Implements hook_token_info(). |