Developer forum

Forum » Development » sending sales order confirmation

sending sales order confirmation


Reply

When you complete a sales order an e-mail is sent to the customer.

I need to send this order confirmaion from another page later on.

How do I do this?

Is ther an easy way to do it?

 

 

 


Replies

 
Reply

Something like this will probably do:

 

Dynamicweb.Templatev2.Template tpl = new Dynamicweb.Templatev2.Template(MyTemplatePath);
Dynamicweb.eCommerce.Orders.Order Order = new Dynamicweb.eCommerce.Orders.Order(MyOrderId);
Dynamicweb.eCommerce.Frontend.Renderer Renderer = new Dynamicweb.eCommerce.Frontend.Renderer();
Renderer.RenderOrder(Oder, tlp);
string MailBody = tpl.Output();

 

 

 
Reply
Sorensen wrote:

Something like this will probably do:

 

Dynamicweb.Templatev2.Template tpl = new Dynamicweb.Templatev2.Template(MyTemplatePath);
Dynamicweb.eCommerce.Orders.Order Order = new Dynamicweb.eCommerce.Orders.Order(MyOrderId);
Dynamicweb.eCommerce.Frontend.Renderer Renderer = new Dynamicweb.eCommerce.Frontend.Renderer();
Renderer.RenderOrder(Oder, tlp);
string MailBody = tpl.Output();

 

 

Im sending the orderId in the Url.
 

How can you get it in DW?

 

I need to send the MailBody to someone.

How do I do that in DW?

 
Reply

You can access the QueryString collection like you would do in any other web application, or you can use Dynamicweb.Base.Request("FieldName").

 

There's no built-in method to send email, but come the newxt update the Order object will have a SendTo method you can use to send the order as a mail. But for now you have to use a renderer and send the mail using your own code.

 
Reply
Sorensen wrote:

You can access the QueryString collection like you would do in any other web application, or you can use Dynamicweb.Base.Request("FieldName").

 

There's no built-in method to send email, but come the newxt update the Order object will have a SendTo method you can use to send the order as a mail. But for now you have to use a renderer and send the mail using your own code.


 

Is the renderer the one creating the mailBody and the manil schoul be sent using the MailMessage object?

 

What is the name of the smtp server?

 

 
Reply

Yes and yes.

 

The smtp server is registered in /Files/GlobalSettings.aspx. You extract the value using Dynamicweb.Base.GetGS("XPath to smtp server node").

 
Nicolai Høeg Pedersen
Reply
Sorensen wrote:

Yes and yes.

 

The smtp server is registered in /Files/GlobalSettings.aspx. You extract the value using Dynamicweb.Base.GetGS("XPath to smtp server node").


 

Dynamicweb.Base.DefaultSmtpServer

 
Reply
paul wrote:
Sorensen wrote:

Something like this will probably do:

 

Dynamicweb.Templatev2.Template tpl = new Dynamicweb.Templatev2.Template(MyTemplatePath);
Dynamicweb.eCommerce.Orders.Order Order = new Dynamicweb.eCommerce.Orders.Order(MyOrderId);
Dynamicweb.eCommerce.Frontend.Renderer Renderer = new Dynamicweb.eCommerce.Frontend.Renderer();
Renderer.RenderOrder(Oder, tlp);
string MailBody = tpl.Output();

 

 

Im sending the orderId in the Url.
 

How can you get it in DW?

 

I need to send the MailBody to someone.

How do I do that in DW?


 

Tryed this but when I add the "Render.RenderOrder(Order, tpl);" I get a System.NullReferenceException:

 

I have added this as a ContentModule and overrided "GetContent()"

 

Whithout the renderer I get the templte and the Order object gets the order information.

 

What could the problem?

 
Reply

If you do it exactly like I wrote, the problem could be the the Order object. Where are you using the code?

 
Reply
Sorensen wrote:

If you do it exactly like I wrote, the problem could be the the Order object. Where are you using the code?


 

I'm using  it as a custom module on a page.

There are information in the order object.

 
Reply

What is the value you use to instantiate the Order object? Could you post your code here?

 
Reply
Sorensen wrote:

What is the value you use to instantiate the Order object? Could you post your code here?


 

here is the code

 

 

public override string GetContent()
{
            string _orderID = Dynamicweb.Base.Request("EcomOrderID");
            string _salesOrder = Dynamicweb.Base.Request("SalesOrder");

          
            Dynamicweb.Templatev2.Template tpl = new Dynamicweb.Templatev2.Template("eCom/Cart/OrderShopEmail.html");
            Dynamicweb.eCommerce.Orders.Order Order = new Dynamicweb.eCommerce.Orders.Order(_orderID);
            //Dynamicweb.Base.w(Order.CustomerAccessUserUserName);
            Dynamicweb.eCommerce.Frontend.Renderer Renderer = new Dynamicweb.eCommerce.Frontend.Renderer();
            Renderer.RenderOrder(Order, tpl);
          
            return tpl.Output();
}

 
Reply

Hm... Weird. What's the exception message? (Source Error and Source File)?

 
Reply
Sorensen wrote:

Hm... Weird. What's the exception message? (Source Error and Source File)?


 

An error occured while attaching module (Dynamicweb.Frontend.Content)

 

System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderOrder(Order Order, Template Template, Boolean ExtendedProperties, Int32 stepReq)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderOrder(Order Order, Template Template, Boolean ExtendedProperties)
   at Dynamicweb.eCommerce.Frontend.Renderer.RenderOrder(Order Order, Template Template)
   at CustomModules.CustomModules.BrommaOrderConfirm.BrommaOrderConfirmFrontEnd.GetContent()
   at Dynamicweb.Frontend.Content.getModule(DataRow& ParagraphRow)
 
Reply

Still getting the same message as soon as I try to add the renderer.

 

 
Reply

Could you try something like:

 

Dynamicweb.Base.w((Order == nothing).ToString());

Dynamicweb.Base.w((tpl == nothing).ToString());

 

 
Reply
Sorensen wrote:

Could you try something like:

 

Dynamicweb.Base.w((Order == nothing).ToString());

Dynamicweb.Base.w((tpl == nothing).ToString());

 

I get:
 

False

False

 

You must be logged in to post in the forum