5

I am experimenting with Commerce 2 and it is amazing, however one thing that I am unable to resolve customizing store e-mails? The default confirmation is not adequate and should be easy to customize using tokens or whatever like drupal core email messages. Can anybody provide a high level overview how to customize the order summary e-mail? Any tips will be greatly appreciated not only by myself, but certainly many other site builders who are stumped over this.

2
  • Please keep in mind that just because you missed something it doesn't mean it wasn't a priority or designed in a logical way. We are missing docs, and that will be improved over time, but there's no need to bundle rants with valid questions. Sep 23 '17 at 16:24
  • @Bojan, you are right and i edited my original message. Sep 24 '17 at 2:31
5

Order receipt emails are powered by Twig templates, just like regular pages. This helps us avoid the inflexibility of tokens and their lack of conditional support ("Only show the Shipping information heading if the token has data"), which were big problems for D7 sites.

You can override the commerce-order-receipt.twig.html template in your theme to customize it.

See https://github.com/drupalcommerce/commerce/blob/8.x-2.x/modules/order/templates/commerce-order-receipt.html.twig

1
  • i should mention that i solved this by creating a custom block with my payment information and then I used twig tweak to insert that block into the template commerce-order-receipt.html.twig and it works beautifully. Thanks again! Sep 26 '17 at 10:40
2

The docs page is obviously still a work in progress (as in, it's stubbed but has no real content at https://docs.drupalcommerce.org/commerce2/developer-guide/orders/customize-order-receipt-emails), but the basic idea is we depend on Swiftmailer for sending HTML e-mails and expect developers to override the default e-mail template we provide. Keep an eye on those docs, as we'll be fleshing them out during DrupalCon week. If you end up with a successful customization, would love to see a blog post about it that we can share with others! : )

2
  • thanks for the reply Ryan. i did spend some time investigating Swiftmailer and customizing the default template was my intention but i did not find a template in the Swiftmail module directory so if you can tell me where the order confirmation template is that would be sufficient for now just to improve it a bit until we get the official documentation. i would be happy to post my process for others once i have a presentable confirmation mail working. Sep 23 '17 at 4:48
  • 1
    You should find it at modules/order/templates/commerce-order-receipt.html.twig. Would definitely appreciate you sharing anything you learn! : ) Sep 24 '17 at 13:06
0

This is the link which you can follow => https://docs.drupalcommerce.org/commerce2/developer-guide/orders/customize-order-receipt-emails

Another solution is to copy the default twig from => commerce/modules/order/templates/commerce-order-receipt.html.twig and then placed into root theme folder of your Drupal 8 project => your_project_name/themes/your_current_theme/templates/(place the default file here)

make the changes as per your requirements. I hope this will work for you guys have a nice day :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.