Developer forum

Forum » Ecommerce - Standard features » Cart Commands : update order line custom field

Cart Commands : update order line custom field

Gaëtan Di Caro
Reply

Hello,

I'm trying to update an order line's custom field with javascript, namely saving a comment on the order line (without placing the order). I read the shopping cart documentation but I haven't found an answer.

Basically I'd like to do something like this : http://test.mysite.dk/kurv?CartCmd=orderline&key=OL5966&Comment=test

But I don't know if there is a specific syntax (I've tested several with no luck) or if you can only do that with the quantity, as the documentation mentions.

 

Otherwise I can do it using the API, but if there is a simpler solution...

 

Thanks


Replies

 
Nicolai Pedersen
Reply

Hi Gaetan

Custom orderline fields are only picked up by add and addmulti commands - so you can use that instead. It will work the same way...

BR Nicolai

 
Gaëtan Di Caro
Reply

Ok, but if I use that, it will add more of the product to the basket (even if I set quantity to 0). I only want to change the order line custom field while in the basket. I guess I'll have to use the api then.

 
Gaëtan Di Caro
Reply

Hm, I can update the orderline field, and I can see the result in the database. However, when I show the basket page, add a new item or call order.save(), my field gets reset. Any idea why ? I use 9.1.17.

Here's what I do in the code :

var orderLine = Dynamicweb.Ecommerce.Orders.OrderLine.GetOrderLineById(orderLineNumber);

        var commentField = orderLine.OrderLineFieldValues.FirstOrDefault(x => x.OrderLineFieldSystemName == "Comment");
        if (commentField == null)
        {
            orderLine.OrderLineFieldValues.Add(new Dynamicweb.Ecommerce.Orders.OrderLineFieldValue("Comment", comment));
        }
        else
        {
            commentField.Value = comment;
        }

        orderLine.Save();

 

You must be logged in to post in the forum