Developer forum

Forum » Development » Print order using API

Print order using API

Lars Larsen
Lars Larsen
Reply

Hi

I need to print an order when orderstate changes. I therefore subscribe to "Ecommerce.Order.State.Changed". From here I print the order. I did that by getting the order using Dynamicweb.Ecommerce.Services.Orders.GetById(OrderId). But doing that orderlines are not organized so discounts are grouped with their parent orderlines. How can I do that?


Replies

 
Nicolai Pedersen
Reply

The orderlines have a parent orderline id property you can use. That is how the rendering does it.

BR Nicolai

 
Lars Larsen
Lars Larsen
Reply

Hi Nicolai​

Yes, I now of the parent orderline id property, but was hoping that the API could give me the order with the discount orderlines organized with their parents, so that I don't have to do that my self.

 
Nicolai Pedersen
Reply
This post has been marked as an answer

There is no advanced stuff in the API. All is simply handled in the renderer.

Votes for this answer: 1
 
Nicolai Pedersen
Reply
This post has been marked as an answer

You also have ProductOrderLines property on the order instead of orderlines.

Votes for this answer: 1
 
Lars Larsen
Lars Larsen
Reply

Hi Nicolai

I fixed it by doing a foreach on ProductOrderLines and in this foreach another foreach on Orderlines in order to print first the product orderline and if this has any discount orderlines I print these in the next loop. Not the most elegant way of doing it, but it works and there are usually not that many orderlines in each loop. so performance vice it seems to be ok I think. Thanks Niclaoi smiley

 

You must be logged in to post in the forum