Developer forum

Forum » Development » Override order confirmation email recipient?

Override order confirmation email recipient?

Dimitrij Jazel
Reply

Hi Guys,

 

In cart module, you can set a list of recepients  https://www.screencast.com/t/FSVlh4JyBOg

When Order is complete, the recepients gets OrderConfirmation email.

 

But what if you need this recepient field to be dynamic, depending on certain conditions in cart - I need to choose an email value from Area.Item settings, and use it as receipient.

/Dmitrij


Replies

 
Nicolai Pedersen
Reply

Then you have to use a notification subscriber.

BR Nicolai

 
Dimitrij Jazel
Reply

Hi Nicolai,

Sure you can, what else would you use. (facepalm)

 

Ofcourse I am using Notification subscriber.

Anyway...

That's what I am using at the moment:

[Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.Cart.CheckoutDoneOrderIsComplete)]
    public class OrderComplete : Dynamicweb.Extensibility.NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            var myArgs = (Dynamicweb.Notifications.eCommerce.Cart.CheckoutDoneOrderIsCompleteArgs)args; 
            var order = myArgs.Order;

My question is how do you access the order confirmation email, and send email to additional different (not-constant) email adress?

If that is possible in the first place.

I tried poking arround in Order object, but could not see any hints.

Maybe I should try subscribing to other notification? I tried several others, but had same result.

 

/Dmitrij

 

 
Nicolai Pedersen
Reply
This post has been marked as an answer

This one maybe?

http://doc.dynamicweb.com/api/html/9d5e6f61-cb38-8bcd-63fb-ed0a603f2bd3.htm

Just a guess!

Votes for this answer: 1
 
Dimitrij Jazel
Reply

Hi again Nicolai,

Great, that helped :) thanks for the info.

Here is my eventual implementation

[Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.eCommerce.Cart.SendingConfirmationMail)]
public class SendingConfirmationMail : Dynamicweb.Extensibility.NotificationSubscriber
{
    public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
    {
        Dynamicweb.Notifications.eCommerce.Cart.SendingConfirmationMailArgs sendingConfirmationMailArgs = args as Dynamicweb.Notifications.eCommerce.Cart.SendingConfirmationMailArgs;
        var m = sendingConfirmationMailArgs.ModuleSettings.Mails.Where(x => x.Recipient == "test@email.com").FirstOrDefault();
        if(m!= null)
        {
            string new_recipient = Dynamicweb.Frontend.PageView.Current().Area.Item["Email"].ToString();

            m.Recipient = new_recipient;
        }
    }
}

 
Nicolai Pedersen
Reply

That might not work if it is the callback from the payment gateway that sends out the email.

BR Nicolai

 

You must be logged in to post in the forum