I'm looking for some clarification/guidance for order emails. I'm trying to implement an admin only email to be sent as confirmation that would contain different email info than is sent to the customer. I've determined that the tasks should be:
Create XSLT mail template for Admin email
Create additional Confirmation Email node in TeaCommerce Admin Section\Confirmation Emails.
Create interface to attach to AfterOrderConfirmationMailSend
My questions are:
For item 2 above, how will Tea Commerce know which email to send to the customer? Will it send both if I add one here?
For item 3 above, how can I grab the node associated to this created from item 2 and the associated XSLT to format the email?
Is there a function for sending email somewhere in the API to basically send the confirmation email again with different parameters (ie, to, from, subject, body)?
What you want to do is pretty straight forward. When you know how to do it, of cause :)
First of all, to explain the email template system in Tea Commerce: - Only the email selected in "general settings > Confirmation E-mail" will be sent automatically when an order is finalized. - As standard, all Tea Commerce e-mails will be sent to the customer AND to any email specified on the e-mail in the Tea Commerce section - When any Tea Commerce e-mail is sent the BeforeMailSend and then the AfterMailSend events are fired - If the mail is the default confirmation mail the BeforeOrderConfirmationMailSend and AfterOrderConfirmationMailSend will be fired as well
Your task will be this: - Create another e-mail in the Tea Commerce section. Just as you have written above. - Hook into the AfterOrderFinalized event (Which is more correct than the AfterOrderConfirmationMailSend, as it is sure to happen when an order is placed). There you will get your new e-mail template with the static EmailTemplate.GetEmailTemplate() method. Now just Send() the e-mail - Hook into the BeforeMailSend event, and check the alias of the email. If it's your new e-mail template remove the "To" reciever, which is the customer.
Order Emails
Hi,
I'm looking for some clarification/guidance for order emails. I'm trying to implement an admin only email to be sent as confirmation that would contain different email info than is sent to the customer. I've determined that the tasks should be:
Hi Hutch,
What you want to do is pretty straight forward. When you know how to do it, of cause :)
First of all, to explain the email template system in Tea Commerce:
- Only the email selected in "general settings > Confirmation E-mail" will be sent automatically when an order is finalized.
- As standard, all Tea Commerce e-mails will be sent to the customer AND to any email specified on the e-mail in the Tea Commerce section
- When any Tea Commerce e-mail is sent the BeforeMailSend and then the AfterMailSend events are fired
- If the mail is the default confirmation mail the BeforeOrderConfirmationMailSend and AfterOrderConfirmationMailSend will be fired as well
Your task will be this:
- Create another e-mail in the Tea Commerce section. Just as you have written above.
- Hook into the AfterOrderFinalized event (Which is more correct than the AfterOrderConfirmationMailSend, as it is sure to happen when an order is placed). There you will get your new e-mail template with the static EmailTemplate.GetEmailTemplate() method. Now just Send() the e-mail
- Hook into the BeforeMailSend event, and check the alias of the email. If it's your new e-mail template remove the "To" reciever, which is the customer.
That's it. Hope it works for you.
/Rune
Thanks for the response! With that I was able to very quickly complete what I was looking to do. :)
For anyone interested, here's the code (be sure to follow the above). If anyone has questions on this feel free to ask!
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net.Mail;
using System.Net.Mime;
using System.Text;
using System.Web;
using System.Xml;
using System.Xml.XPath;
using TeaCommerce.Data;
using TeaCommerce.Data.Extensibility;
using TeaCommerce.Data.Tools;
using TeaCommerce.WebShop.Integration;
using umbraco.BusinessLogic;
namespace TeaCommerce.WebShop.Integration
{
public class LicenseExtension : ITeaCommerceExtension
{
#region ITeaCommerceExtension Members
string _strEmailAlias = ConfigurationManager.AppSettings["AdminOrderEmailAlias"].ToString();
public void Initialize()
{
WebshopEvents.AfterOrderFinalized += OrderController_AfterOrderFinalized;
WebshopEvents.BeforeMailSend += OrderController_BeforeMailSend;
}
#endregion
void OrderController_AfterOrderFinalized(Order order, Data.Payment.CallbackInfo pci)
{
EmailTemplate.GetEmailTemplate(_strEmailAlias).Send(order);
WebshopEvents.BeforeMailSend += OrderController_BeforeMailSend;
}
void OrderController_BeforeMailSend(Order order, MailMessage mail, EmailTemplate emailTemplate)
{
string strEmailTo = ConfigurationManager.AppSettings["AdminOrderEmailTo"].ToString();
if (emailTemplate.Alias == _strEmailAlias)
{
mail.To.Clear();
mail.To.Add(new MailAddress(strEmailTo));
}
}
}
}
is working on a reply...