Sup fellow nerds,
Is there a better way to completely remove all orderlines from an order (in the db as well) through code than this:
List<Dynamicweb.Ecommerce.Orders.OrderLine> orderLines = dwOrder.OrderLines.ToList();
foreach (Dynamicweb.Ecommerce.Orders.OrderLine orderLine in orderLines)
{
dwOrder.OrderLines.Remove(orderLine);
Services.OrderLines.Delete(orderLine.Id);
}
At first I tried this:
dwOrder.OrderLines.Clear();
Services.Orders.Save(dwOrder);
That would remove the OrderLines from the Order object, but they still existed in the EcomOrderLines table, and after each recycle of the web the orderlines got replicated, so if I started out with 5 lines and recycled, I had 10, then 15, 20... :)
Would be nice if the OrderLine or Order services included a method to yeet all orderlines at once.
Best regards,
Arnór