I have a shopping cart system (part of the one that came with CF Server)
and i would like to have users be able to order multiple items with
different quantities. IE a user could order 4 red hammers, 2 blue hammers,
and 5 green hammers in one click of the button.
When they hit the submit button i get these Form variables.
FORM.SKU = 12,34,23
FORM.QUANTITY = 1,3,2
Here is my existing code to add the items, but right now it is setup to add
only one item at a time with one quantity. How can i loop over this code
with the proper SKU, and Quanity for each part of the form variables
list? If i use <cfloop INDEX="loopingSKU" LIST="#form.SKU#"> then all i
can loop is the SKU, the Quantity does not loop.
<!--- If the item is already in the basket... --->
<CFIF ListFind(Session.StoreItems, Form.SKU) NEQ 0>
<!--- Find where in the basket it is --->
<CFSET ItemPosition = ListFind(Session.StoreItems, Form.SKU)>
<!--- Find out how many of the item are already in the basket --->
<CFSET CurrentQuantity = ListGetAt(Session.StoreQuantities,
ItemPosition)>
<!--- Now we add one to what's already in there --->
<CFSET Session.StoreQuantities = ListSetAt(Session.StoreQuantities,
ItemPosition, CurrentQuantity + Form.Quantity)>
<!--- Otherwise, just add it to the basket --->
<CFELSE>
<CFSET Session.StoreItems = ListAppend(Session.StoreItems, Form.SKU)>
<CFSET Session.StoreQuantities = ListAppend(Session.StoreQuantities,
Form.Quantity)>
</CFIF>
Any help would be appreciated. Hopefully i explained this without making
it super confusing.
Thanks,
Chad
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists