Hi there,
I have the following code to add a product to the cart:
private static void CreateOrderLine(Product product, double quantity, double price) { var order = Context.Cart; if (product == null) { return; } var ol = new OrderLine { Product = product, ProductID = product.ID, ProductName = product.Name, ProductNumber = product.Number, ProductVariantID = string.IsNullOrEmpty(product.VariantID) ? product.VirtualVariantID : product.VariantID, Quantity = quantity, Type = ((int)OrderLine.OrderLineType.Product).ToString(), Modified = DateTime.Now, Order = order, AllowOverridePrices = true }; ol.SetUnitPrice(new PriceInfo { PriceWithVAT = price }, true); order.OrderLines.Add(ol); order.ClearCachedPrices(); Context.SetCart(order); }
The product is added to the cart successfully and the price I am assinging shows up as the line item price.
However, the total of the order remains zero. Is there something I need to do to force the cart to recalculate itself?
Thanks,
Imar