I have been playing around with a tutorial and it has a section of a cart
written in <cfscript> which I really don't understand.  Can someone please
decode this into regular CF. Here is the script:

                <cfscript>
                        if (not(isdefined("session.cart"))) {                          
 // Check to make sure that the
Shopping cart structure exists.
                                session.cart = structnew();
                                }

                        // The item structure we are going to use to store the items 
in the cart
                        // is going to have four parts...
                        //              1.  The item id
                        //              2.  The item name
                        //              3.  The price per unit
                        //              4.  The quantity

                        tempvalue =
listtoarray('#attributes.id#,#attributes.name#,#attributes.price#,#attribute
s.quantity#');

                        // if the item is not yet in the cart, simply add it to the 
cart
                        if (not(structKeyExists(session.cart, attributes.name))) {
                                StructInsert(session.cart,attributes.name,tempvalue);

                        }

                        // if the item is already in the cart, update the item quantity
                        else {
                                
tempvalue[4]=session.cart[attributes.name][4]+attributes.quantity;
                                StructUpdate(session.cart,attributes.name,tempvalue);
                        }
                </cfscript>

Thanks,
Rich



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to