I've got a simple shopping cart that stores cart selections in a structure. 
Works great. It simply checks for the itemID, then either adds the itemID if 
not found or updates the quantity key if the itemID exists. 

<cfscript>
tempvalue = 
listtoarray('#attributes.id#,#attributes.name#,#attributes.price#,#attributes.quantity#,#attributes.option1#');
        if (not(structKeyExists(session.cart, attributes.id))) {
        StructInsert(session.cart,attributes.id,tempvalue);}

        else {  tempvalue[4]=session.cart[attributes.id][4]+attributes.quantity;
        StructUpdate(session.cart,attributes.id,tempvalue);}
</cfscript>


Now, the trouble I'm having, is displaying a page with a product that has 
options associated with it such as size. For example a shirt. Since the above 
structure updates the quanitity relative to the itemID, I'm forced to give each 
shirt,size combo it's own itemID. So when a user adds another shirt size large, 
the itemid for shirt size large quantity is updated. On the page where the user 
sees the items offered, I can't seem be able to display the shirts any way 
other than by itemid, so I end up with shirt size large, shirt size medium, 
shirt size small...instead of shirt, choose which size select box. 

If I add an options table in the database and relate it to the options filed in 
the product, it makes it easy to display, but then when the item is added to 
the cart, there's just the one id of the item. If a user goes back and adds a 
second shirt, with a different size, I've got nowhere to store the size option 
in my structure..since the itemid's are the same, all I can do is overwrite the 
option key which won't be correct. 

This seems like it should be so easy, am I missing someting obvious?

jeff 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:257710
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to