I am trying to develop a simple shopping cart.
I have created an array of structures for this as follows.
<cfif not Isdefined("Session.ShoppingCart")>
<cfset SESSION.shoppingcart = ArrayNEW(1)>
I would like to delete a given entry in the array given a
particular FORM.id, say id = 220
Here is my code to try and delete the item
<cfloop from="1" to="#ArrayLen(SESSION.shoppingcart)#"
.id eq FORM.id>
<cfset foo = structdelete(SESSION.shoppingcart,
This is not working. I guess perhaps I should delete the
array entry, but I can't figure out how to do this. Thanks in
Duh, I figured it out.
<cfset bar = arraydeleteat(SESSION.shoppingcart, i)>
I am having a problem when looping not sure why. I think
because I'm deleting an item in the array it tries to loop to that
index in the array. It will say "The element at position 3 cannot
be found". I guess I normally wouldn't have to delete multiple
positions in the array with a normal shopping cart unless they
selected two different id's. I'll work on a more advanced shopping
cart and post again.