Hello!
I am trying to add orderlines to an order using 'new OrderService().CreateOrderLine()', but the price is not updating. Even if I use the old deprecated method Order.CreateOrderLine nothing happens. This is my (simplified) code:
var order = new Order();
var orderService = new OrderService();
foreach (var product in productsList)
{
order.CreateOrderLine(product, quantity, StockUnit.GetProductStockUnits(product).FirstOrDefault(), product.Price);
orderService.CreateOrderLine(order, product, quantity, StockUnit.GetProductStockUnits(product).FirstOrDefault(), product.Price);
}
As stated above, neither of these work with the price but result with an orderline added to the cart, which is good. See the first attachment. I know for a fact that the variable product in the foreach-loop has a price because I print it out on the page to be sure.
However, if I manually add a product to the cart normally while I have these products in the cart, they get updated and get the correct prices. See attachment 2.
Is there like a save or "CalculatePrice"-function that I have to call?