Developer forum

Forum » Development » Reuse existing order renderer

Reuse existing order renderer

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a web service in a custom Dynamicweb solution that sends out order shipping confrmation e-mails based on the request by an ERP. I have most of it working but would like to use an existing order renderer to allow the template developer to use existing template tags for the order, order lines and so on.

I looked at the Frontend.Renderer and Frontend.Cart.Renderer but they seem to depend on a Pageview or (for some reason) try to redirect me away when I call RenderOrder.

Is there an existing RenderOrder method (or similar) that I can reuse to render the details of an order into a template?

Thanks,

Imar

 


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Imar

Yes, they depend on a pageview. You can do it like this. Or create a pageview instance of the page where the cart module is on, and set the pageview.redirect = False to avoid redirects.

var r = new eCommerce.Frontend.Renderer(Dynamicweb.Frontend.PageView.Current());
r.RenderOrder(order, formTemplate);

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks. I tried calling this:

var pageView = PageView.GetPageviewByPageID(51);

but it throws a NullReferenceException. Is this how I am supposed to call it? Note: I am calling this from an ASMX WebService.

Imar

 
Nicolai Høeg Pedersen
Reply

Yes, that is the way.

Could be missing HttpContext. Is it a WCF webservice or good old one?

Try this one:

<system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> </system.serviceModel>

Or does it have to be a webservice? You could make a regular page in DW returning an XML document...

Nicolai

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Nicolai,

Yes, it's a goold old ASMX web service. It has to be one, as it's part of a larger API / contract with other methods to expose and accept data.

Your WCF config put me on the right track, though. I had to add session state to the Web Method:

[WebMethod(EnableSession = true)]

It now loads correctly so let's see if that fixes my other issues.

Thanks,

Imar

 
Nicolai Høeg Pedersen
Reply

Ok, great!

Let me know if you encounter more issues.

 

You must be logged in to post in the forum