Developer forum

Forum » Development » Remove items from the shoppingcart

Remove items from the shoppingcart


Reply
 Hello DW, 

I was wondering if it is possible to remove mutiple products from the shopping cart in one request. Sort og the opposite of what this forum post explains how to do: http://engage.dynamicweb-cms.com/Forum-5.aspx?PID=34&action=ShowThread&ThreadID=1215

 /Thor




Replies

 
Nicolai Høeg Pedersen
Reply
Try having a look at this article:
http://engage.dynamicweb-cms.com/Updating-the-shopping-cart-content-197.aspx

You need the command "updateorderlines" and set the "QuantityOrderLine#" to 0.
 
Reply
Hello again and thank you for your answer.

I tried out your example, but when i set the quantity to 0 on two different products and update the form i receive this error:


An error occured while attaching module (Dynamicweb.Frontend.Content)

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
   at Dynamicweb.eCommerce.Frontend.Cart.Frontend.UpdateCartStep1(Order order)
   at Dynamicweb.eCommerce.Frontend.Cart.Frontend.GetContent()
   at Dynamicweb.Frontend.Content.getModule(DataRow& ParagraphRow)

I copy-pasted the entire example from the link your posted. 
So i can't figure out if i am doing something wrong or the method simply does'nt work.

Thanks in advance

/Thor
 
Reply

Sorry, thought this was a code issue first:)
---

Hi,

You could iterate through a copy of your orderlinecollection to retrieve the a reference point (e.g. index number), and then remove the lines in question on the original instance. If you need to remove multiple lines, remember to calculate for already removed lines it you're using the index key;-)

BR.
Lars

 

You must be logged in to post in the forum