Developer forum

Forum » Development » Order.SendTo - a little help

Order.SendTo - a little help

Jonas Mersholm
Reply

Hi! :)

Using the CheckoutDoneOrderIsCompleted notification to run events when an order is complete. Everything so far works well. Now, i want to send the order to a few email adresses. I found the following line in part of your documentation

 

 Order.SendTo(ref pageView, oid, emailAddresses[cnt], SenderMail, ref t);

 

My question is now. How would i go around getting a pageview and the default order email template, so that i can send the exact same order complete mail to a few different email adresses? 

More generally: How would i use this method correctly?

 

Thanks in advance.

Jonas


Replies

 
Vladimir
Reply

Hi Jonas,

First of all, cart' module settings contain section "Notification e-mails "  to send mails(probably it will be suitable)..

If not:

1) Pageview:

              a) Dynamicweb.Frontend.PageView.Current  - if it is not null, and it points to page with cart settings (depended from used payment gateway)

              b) Dynamicweb.Frontend.PageView.GetPageviewByPageID(pageID) 

2) order email template

              a) Maybe it will be more convenient to use Notifications.eCommerce.Cart.SendMails notification, it is sent exact after CheckoutDoneOrderIsCompleted.  And it will contain cart ModuleSettings where you can find template in Mails property

              b) another notification - Notifications.eCommerce.Cart.SendingConfirmationMail: it is sent for each recipient (customer and from cart ModuleSettings Mails)

              c) or find Module settings:

                    var paragraph = Content.Paragraph.GetParagraphsByPageID(pageID). 
                         Where(x => x.ModuleSystemName == "eCom_CartV2").FirstOrDefault();

                    var settings = new ModuleSettings(paragraph.ModuleProperties);

I hope that is help you

Best regards,

Vladimir

 

 
Jonas Mersholm
Reply

Hi Vladimir, thank you.

Your response lead me a little closer to a correct result.

 

It now sends me an email, when an order completes using the "SendMails" notification - the email is empty though!

 

Dynamicweb.Rendering.Template mt = new Dynamicweb.Rendering.Template("~/files/Templates/eCom/Order/PrintOrder.html");                   
Dynamicweb.Frontend.PageView pw = Dynamicweb.Frontend.PageView.GetPageviewByPageID(21);
myArgs.Order.SendTo(ref pw, user.Email, "order@mail.com", ref mt);

The page, used as the pageview, is the "basket" page. where my checkout procedure is located.

The template is verified to exist at that position.

 

What am i doing wrong here? 

Thanks in advance.

Jonas

 
Morten Bengtson
Reply

Hi Jonas,

I think you just need to change the path to the template. Try this instead...

Dynamicweb.Rendering.Template mt = new Dynamicweb.Rendering.Template("eCom/Order/PrintOrder.html");

However, if you don't need to do any advanced stuff with your emails, you can just use the standard notification emails as Vladimir suggested.

 

 

You must be logged in to post in the forum