|
Drupal example source code file (uc_payment.tokens.inc)
The uc_payment.tokens.inc Drupal example source code
<?php
/**
* @file
* Token hooks.
*/
/**
* Implements hook_token_info().
*/
function uc_payment_token_info() {
$order['payment-method'] = array(
'name' => t('Payment method'),
'description' => t('The payment method of the order.'),
);
$order['payment-balance'] = array(
'name' => t('Balance'),
'description' => t('The payment balance of the order'),
);
return array(
'tokens' => array('uc_order' => $order),
);
}
/**
* Implements hook_tokens().
*/
function uc_payment_tokens($type, $tokens, $data = array(), $options = array()) {
$values = array();
if ($type == 'uc_order' && !empty($data['uc_order'])) {
$order = $data['uc_order'];
if (isset($tokens['payment-method'])) {
$original = $tokens['payment-method'];
$values[$original] = _uc_payment_method_data($order->payment_method, 'review');
if (empty($values[$original])) {
$values[$original] = _uc_payment_method_data($order->payment_method, 'name');
}
}
if (isset($tokens['payment-balance'])) {
$original = $tokens['payment-balance'];
$values[$original] = uc_currency_format(uc_payment_balance($order));
}
}
return $values;
}
Other Drupal examples (source code examples)Here is a short list of links related to this Drupal uc_payment.tokens.inc source code file: |
"Drupal" is a registered trademark of Dries Buytaert.
our drupal tutorials and examples
Sponsored by:
Mat-Su Valley Programming (Wasilla and Palmer, Alaska)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.