You are here

function uc_addresses_token_info in Ubercart Addresses 7

Implements hook_token_info().

File

./uc_addresses.tokens.inc, line 11
Hook implementations for token module.

Code

function uc_addresses_token_info() {
  $types['uc_addresses'] = array(
    'name' => t('Ubercart Addresses'),
    'description' => t('Tokens related to individual addresses'),
    'needs-data' => 'uc_addresses',
  );
  $tokens = array();

  // Ubercart Addresses tokens.
  $tokens['uc_addresses'] = array();
  $address = UcAddressesAddress::newAddress();
  $fields = uc_addresses_get_address_field_handler_instances($address, 'token');
  foreach ($fields as $fieldname => $handler) {
    $tokens['uc_addresses'] = array_merge($tokens['uc_addresses'], $handler
      ->getTokenInfo());
  }

  // Ubercart order tokens.
  $tokens['uc_order']['uc-addresses-shipping-address'] = array(
    'name' => t('Shipping address'),
    'description' => t('The order shipping address, formatted with the Ubercart Addresses module.'),
    'type' => 'uc_addresses',
  );
  $tokens['uc_order']['uc-addresses-billing-address'] = array(
    'name' => t('Billing address'),
    'description' => t('The order billing address, formatted with the Ubercart Addresses module.'),
    'type' => 'uc_addresses',
  );

  // User tokens.
  $tokens['user']['default-shipping-address'] = array(
    'name' => t('Default shipping address'),
    'description' => t('The default shipping address, formatted with the Ubercart Addresses module.'),
    'type' => 'uc_addresses',
  );
  $tokens['user']['default-billing-address'] = array(
    'name' => t('Default billing address'),
    'description' => t('The default billing address, formatted with the Ubercart Addresses module.'),
    'type' => 'uc_addresses',
  );
  return array(
    'types' => $types,
    'tokens' => $tokens,
  );
}