function uc_payment_tokens in Ubercart 8.4
Same name and namespace in other branches
- 7.3 payment/uc_payment/uc_payment.tokens.inc \uc_payment_tokens()
Implements hook_tokens().
File
- payment/
uc_payment/ uc_payment.tokens.inc, line 32 - Token hooks for the uc_payment module.
Code
function uc_payment_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$values = [];
if ($type == 'uc_order' && !empty($data['uc_order'])) {
$order = $data['uc_order'];
if (isset($tokens['payment-method'])) {
$original = $tokens['payment-method'];
$method = PaymentMethod::loadFromOrder($order);
$values[$original] = $method ? $method
->getPlugin()
->cartReviewTitle() : t('Other');
}
if (isset($tokens['payment-balance'])) {
$original = $tokens['payment-balance'];
$values[$original] = uc_currency_format(uc_payment_balance($order));
}
}
return $values;
}