Developer forum

Forum » Development » Reordering the orderlines

Reordering the orderlines

Steen Nørgaard Perdersen
Reply
Hi,

i have basket, where I swap some products based on a "replace this product" function on the basket.

Actually, I had troubles with this, so I add a new one with the relevant parameters, and pass along the existing orderline number. This works ok.

My problem is, that the new orderline is placed last in the list of order lines:
1. product A - user wishes to swap to product D
2. product B
3. product C

List now returns:
1. product B
2. product C
3. Product D -> this is the cartlineAdded, which I want at same place as the "old one" - product A, in this case as first line.

I do the replacing (remove the old line) on cartlineadded... Can I affect the ordering here to affect the rendering order of the lines?

I have opted not to replace the product on the orderline, as there are very different options regarding orderlinefieldvalues on the different products.


Any suggestions??

Regards,

Steen/Bleau

Replies

 
Nicolai Høeg Pedersen
Reply
Hi Steen

The orderlines are ordered by OrderLineID, OrderLineParentLineID - so if you can reuse just the OrderLineID on your replaced orderline, your sorting would be correct. Now, I have not seen you code, but it should be possible - the ID's are just strings, so you can simply replace them if you keep track of them.

Hope this helps.

 
Steen Nørgaard Perdersen
Reply

Well, tried that...(deleting old orderline, reusing the number..)

But if you say it should work, i'll try once more - tracking all the changes to see if I missed something.

Maybe a cart save or reload?


Thanks,

Steen
 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer
You could try setting HttpContext.Current.Session("EcomCart") to nothing after the update
Votes for this answer: 0
 
Steen Nørgaard Perdersen
Reply

Thanks Nicolai,

could not do it api style but the following did do the job

 
                var sql = string.Format("update ecomorderlines set orderlineid ='{0}' where orderlineid='{1}'",Base.ChkString(Base.Request("SubstituteMe")),myArgs.AddedLine.ID);      
                myArgs.Cart.OrderLines.RemoveLine(Base.ChkString(Base.Request("SubstituteMe")));
                HttpContext.Current.Session["EcomCart"] = null;
                Database.ExecuteNonQuery(sql, "");
 
Nicolai Høeg Pedersen
Reply
Hi Steen

Glad you got it to work - and thanks for sharing!

 

You must be logged in to post in the forum