Posted on 13/01/2021 12:44:27
Hi Jeppe
Thanks for your explanation. Yes my code above is a bit messed up. I see that now when you point it out. I had tried a lot of things and then you end up with code that's not always very nice. But now I have this piece of code that works:
var specialProd = Dynamicweb.Ecommerce.Services.Products.GetProductById("PROD224", "", args.Order.LanguageId, false);
var ol = Dynamicweb.Ecommerce.Services.OrderLines.Create(args.Order, specialProd, 1, null, null);
Dynamicweb.Ecommerce.Services.OrderLines.SetUnitPrice(ol, 100, true);
Dynamicweb.Ecommerce.Services.Orders.Save(args.Order);
Previously in earlier Dynamicweb versions I have added orderlines using the API and had no issues with that. Since then the API has been changed and expanded, which I find good. But this of course also makes it more complex, and much of it is not documented. It would be nice if there were some documention for the most basic use cases