Developer forum

Forum » Ecommerce - Standard features » Update/change a OrderLineField in cart without duplicate OrderLine

Update/change a OrderLineField in cart without duplicate OrderLine

Morten S. Hvid
Reply

Hi,

Is it possible to change a OrderLineFieldValue in the cart without having the product to be added multiple times?

Im adding a value using:

var commentField = ol.OrderLineFieldValues.FirstOrDefault(x => x.OrderLineFieldSystemName == "CommentField");
if (commentField != null)
{
commentField.Value = "MyValue";
}
ol.Save();

With the above the value gets saved on the orderline.
If I increase or decrease the quantity in the card - the existing orderline is update (quantity) - and the OrderLineValue is update - just as it should be.
(The orderlinefieldvalue is based/calculated on the quantity in the cart).

But if  I add the exact same product from the productpage to the cart again - a new orderline is added with the same product.
I want to avoid that and just update the quantity and on top of that - change the OrderLineFieldValue based on the total quantity.

How is that possible?

 

DW 8.9.2.18


Replies

 
Nicolai Pedersen
Reply

If the product no 2 you add have different orderlinefield values, another orderline is added because they are different.

If you submit the exact same product and orderlines, it should update the quantity. Alternatively on the product detail, check if the cart contains the product already and change the add to cart link to be an orderline increase call.

NP

 

You must be logged in to post in the forum