When an order is submitted on our D7 site an email is sent to us with all the details of the order, including the payment method.
I use the token [commerce-order:payment-method]
in the commerce email configuration page , which works fine, but I would like to change the value of that token to something that is more readable, like "This order is paid".
This is what I have so far in a custom module:
function mymodule_tokens_alter(array &$replacements, array $context) {
if ($context['type'] == 'commerce-order') {
// Find token starting with commerce-order:payment-method.
if ($value_tokens = token_find_with_prefix($context['tokens'], 'payment-method')) {
if (!empty($value_tokens['payment-method']) && $value_tokens['payment-method'] === 'card_payment') {
$replacements[$value_tokens['payment-method']] = 'This order is paid';
}
}
}
}
The token's value still is card_payment, when the email arrives, so I have probably misunderstood something. Anyone?