Developer forum

Forum » Dynamicweb 10 » Missing child orderlines in OrderLines loop

Missing child orderlines in OrderLines loop

Cátia Torego
Reply

Hi,

We are adding some child orderlines to the cart when a new orderline is added, with the notification Dynamicweb.Ecommerce.Notifications.Ecommerce.Cart.Line.Added
This is how we are creating the child orderline:

var order = orderLine.Order;
var skuProduct = Dynamicweb.Ecommerce.Services.Products.GetProductByNumber(sku, order.LanguageId);

if (skuProduct == null) return;

var childOrderLine = new OrderLine(order)
{
    Id = "",
    ParentLineId = orderLine.Id,
    Modified = DateTime.Now,
    ProductId = skuProduct.Id,
    ProductNumber = skuProduct.Number,
    ProductName = skuProduct.Name,
    ProductVariantId = skuProduct.VariantId,
    Product = skuProduct,
    Quantity = orderLine.Quantity,
    Order = orderLine.Order,
    OrderLineType = OrderLineType.Fixed,
    UnitPrice = skuProduct.GetPrice(new PriceContext(order.Currency, order.VatCountry))
};

orderLine.Order.OrderLines.Add(childOrderLine);
Dynamicweb.Ecommerce.Services.Orders.ForcePriceRecalculation(order);
Dynamicweb.Ecommerce.Services.Orders.Save(order);


We loop the existing orderlines in the frontend to display some information from the child orderlines.

foreach (var ol in GetLoop("OrderLines")){...}

At first the child orderlines are present in the orderlines loop, but if we clear the OrderService cache they are gone.
The child orderlines are still in the DB and are still visible if we look at the order in the backoffice, they just don't show in the frontend anymore.

If we remove this line
 ParentLineId = orderLine.Id,
and create a normal orderline instead the issue doesn't happen.

DW version: 10.15.4


Replies

 

You must be logged in to post in the forum