Most Drupal Commerce sites, one would think, are likely to want to send emails to their customers detailing the contents and total cost of their order for confirmation purposes. However, it can be surprisingly difficult to show all of the information required, so I thought I’d write something down to make sure I have something to refer to next time this comes up!
By default, the tokens available to the commerce mail module only show each individual line item and the order total. There is no separate token to show taxes or shipping costs, which is very confusing for the customer.
I trawled through the comments on several issues on drupal.org before finding the right issue (www.drupal.org/node/1566938), where post #4 by Nicolas Bouteille (kudos) pointed me in the right direction.
Basically, you have to enable the token view mode inside the ‘Custom Display Settings’ part of Commerce’s order settings. You then have to ensure that the ‘Order total’ field is configured in the token view mode to display ‘Formatted amount with components’.
Then, when you use the
[commerce-order:commerce_order_total] token in an email, it should helpfully break the total down into subtotal, VAT, and shipping. Splendid.