function payment_tokens in Payment 7
Implements hook_tokens().
File
- ./
payment.tokens.inc, line 36 - Token integration.
Code
function payment_tokens($type, array $tokens, array $data = array(), array $option = array()) {
$replacements = array();
if ($type == 'payment') {
/** @var Payment $payment */
$payment = $data['payment'];
foreach ($tokens as $name => $token) {
$pattern = '#^' . PAYMENT_LINE_ITEM_TOKEN_PREFIX . '#';
if (preg_match($pattern, $name) && ($line_items = $payment
->getLineItems(preg_replace($pattern, '', $name)))) {
$replacements[$token] = $payment
->totalAmount(TRUE, $line_items);
}
}
}
return $replacements;
}