Developer forum

Forum » Development » Out stock need split to new Order

Out stock need split to new Order

George Nelzo Pereira
Reply
Hi everybody.
I need to create an order and after finishing or before, I need to check if there is any product out of stock, if have any i will need to create another order.
Keeping the original just with products in stock and create that new just with products out of stock.
There is something to do this? If I need to create, anyone have any suggestions to do this in the best place and time?

George Nelzo

Replies

 
Morten Snedker
Reply
This post has been marked as an answer

Hi George,

 

At a desired step use the notification API to evaluate the order. You can find more here.

From the hip, having o being your cart:

foreach (Dynamicweb.eCommerce.Orders.OrderLine ol in o.OrderLines)
{
   if (ol.Stock == 0)
   {
      MyNewOrderObject.OrderLines.Add(ol); 
      o.OrderLines.RemoveLine(ol.ID);
    }
}
o.Save();
MyNewOrderObject.Save();

 

Hope it sheds some light!

 

Best regards / Snedker

 

Votes for this answer: 1
 
George Nelzo Pereira
Reply

I thought there was something by default in DW, just for choose by option...
But that is ok...
I will do that way...
 

Thanks a lot, and have a good day.

 

You must be logged in to post in the forum