You are here

function uc_payment_tokens in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 payment/uc_payment/uc_payment.tokens.inc \uc_payment_tokens()

Implements hook_tokens().

File

payment/uc_payment/uc_payment.tokens.inc, line 29
Token hooks for the uc_payment module.

Code

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;
}