Developer forum

Forum » Dynamicweb 10 » Child orderlines (parentorderlineid <> '') are ignored for Quotes

Child orderlines (parentorderlineid <> '') are ignored for Quotes

Kenneth Holm
Reply

In 10.17.0 any orderline that uses the parentorderlineid seems to be ignored in any ecommerce calculations. I'm specifically testing with orderlinetype = 2 (fixed), but I tried setting it to 0 (product) as well. Seems to be completely ignored for Quotes.

I've tested changing DB values, resetting services and just using the ecom module in backend to change values on orderlines to trigger an update. - Same result.

 

If I remove the orderlineparentlineid value in the ecomorderlines table, and trigger an update by changing one of the orderlines, it seems to be working just fine.

Conclusion: If orderlineparentlineid is not empty, it gets ignored in calculations (at least for orderlinetype 0 and 2).

 

/Kenneth


Replies

 
Rasmus Sanggaard Dynamicweb Employee
Rasmus Sanggaard
Reply

Hi Kenneth,

 

it's a bug. #24721 

 

BR Rasmus Sanggard

 
Kenneth Holm
Reply

Thanks Rasmus,

 

I just tested in 10.15.7 too, seems to be there too. - Again just for Quotes, not for Orders.

 

/Kenneth

 
Rasmus Sanggaard Dynamicweb Employee
Rasmus Sanggaard
Reply

Hi Kenneth,

 

Seems I was too fast with the bug. We can't seem to reproduce it. We get the same behavaior on Order and Quotes.

How is the master/parent products pricing setup?

 BR Rasmus Sanggaard

 

 

 
Kenneth Holm
Reply

Hi Rasmus,

 

I don't have that setting anywhere. However I managed to fix my issue my temporarily setting the OrderLineType.Fixed to .Products, force a recalculation and discount calculation, and setting them back to fixed. It didnt matter in my solution that they are fixed really.

Thanks for the help. If i find the time to dig into this further I will return with some more concrete evidence.

 

/Kenneth

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Kenneth

If you create a product of type bundle, you will have that setting.

But it sounds like you maybe created the parent/child relations in code?

 
Kenneth Holm
Reply

Hi NP,

Yes, it's created as an extra orderline in the cart, with a ParentLineOrderId matching.

            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)),
                OrderLineFieldValues = orderlineFields
            };
 
            orderLine.Order.OrderLines.Add(childOrderLine);
            Dynamicweb.Ecommerce.Services.Orders.ForcePriceRecalculation(order);
            Dynamicweb.Ecommerce.Services.Orders.Save(order);
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Ok - then you have to handle the price logic your self.

 
Kenneth Holm
Reply

How would you do it different then, to leverage the price engine and calculations in DW?

/Kenneth

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

What happens if you set the orderline type to product - or what was orderlinetype before you changed it to fixed?

 
Kenneth Holm
Reply

Then it's working as expected. My main issue is that the FIXED orderline is not added to the OrderTotal, unless I do this hack. And with it the OrderTotalDiscountWithoutVAT is 0.

 

            // Recalc order as Wholesaler
            // Set Personalization Orderlines to Product
            foreach (var personalizationOrderline in orderArgs.Order.OrderLines.Where(x => !string.IsNullOrEmpty(x.ParentLineId) && x.OrderLineFieldValues.Any(x => x.OrderLineFieldSystemName == Constants.OrderFields.PersonalizationGUID && !string.IsNullOrEmpty(x.Value))))
            {
                personalizationOrderline.OrderLineType = OrderLineType.Product;
            }
 
            orderArgs.Order.CustomerAccessUserId = wholesaleUser.ID;
            orderArgs.Order.CustomerNumber = wholesaleUser.CustomerNumber;
            Dynamicweb.Ecommerce.Services.Orders.SetUserDetailsOnOrder(orderArgs.Order, wholesaleUser, true);
            Dynamicweb.Ecommerce.Services.Orders.CalculateDiscounts(orderArgs.Order, true);
            Dynamicweb.Ecommerce.Services.Orders.ForcePriceRecalculation(orderArgs.Order);
 
            // Set Provider UserId for them to have access
            orderArgs.Order.SecondaryUserId = currentUser.ID;
 
            // Set Personalization Orders back to Fixed
            foreach (var personalizationOrderline in orderArgs.Order.OrderLines.Where(x => !string.IsNullOrEmpty(x.ParentLineId) && x.OrderLineFieldValues.Any(x => x.OrderLineFieldSystemName == Constants.OrderFields.PersonalizationGUID && !string.IsNullOrEmpty(x.Value))))
            {
                personalizationOrderline.OrderLineType = OrderLineType.Fixed;
            }
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Ok - let's start over.... You lost me ;-)

What are you trying to accomplish (not what are you doing in code). I want to understand the problem you are implenting a solution for.

 
Kenneth Holm
Reply

The minimum amount of rework, mostly! :-)

 

I'm converting an order from a User-entity: "Provider" to a User-entity: "Wholesaler", after that conversion I want to recalculate the price in the order, since the Wholesaler has discount rules and pricerules in the price matrix that needs to be applied.

The reason we are adding orderlines, is due to a customization posibility in the frontend, where customers can decide text, color and artwork for engravings. Depending on the customization settings, different SKU's is added to the cart, to maintain correct prices during the user-flow, and in the end for price calculations before send to ERP.

 

I give it might be unnessecary to have set the orderlines to fixed, but I hoped to just apply my "hotfix" to avoid changing references for throughout multiple template files. Correct way would no doubt be with a orderlinefield to identify the orderlines instead of using fixed (sorry for that bad usage).

 

/Kenneth

 

You must be logged in to post in the forum