Creating Custom Commerce Email Templates

umbraco 13.9.2

commerce v13.2.4

Hi, looing at the docs for creating custom email templates, there is a code snippet however the interface IEmailTemplate is nowhere to be found. Are the docs incorrect or is there a missing reference? I’ve checked all the umbraco commerce assemblies for IEmailTemplateand I cannot see it (but could be blind lol)

Customizing Templates | Umbraco Commerce

Oh wow, I’m not sure where those docs are from but they are way off. I’ll get that added to the backlog to sort out.

This is actually how you create your own email templates

var confirmationEmailTemplate = EmailTemplate.Create(args.UnitOfWork, args.Model.Id,
    "orderConfirmation", "Order Confirmation")
    .SetCategory(TemplateCategory.Order)
    .SetSubject("Order Confirmation")
    .SetSender("Umbraco Commerce", "[email protected]")
    .SetSendToCustomer(true)
    .SetTemplateView("~/Views/UmbracoCommerce/Templates/Email/OrderConfirmationEmail.cshtml");

_emailTemplateService.SaveEmailTemplate(confirmationEmailTemplate);

This needs to happen inside a unit of work.

Hi Matt

Is ok, in the backoffice the template path is editable so i just specified my modified template path and baddabing, sorted!

Yea, my code example is basically how to do in code what you can do via the backoffice anyways so that’s equally as good an option.

Now I need to go figure out where on earth those docs came from :man_facepalming:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.