Time:
Scotland: Fri, 7:20 pm
Rhode Island: Fri, 2:20 pm
Florida: Fri, 2:20 pm
New Mexico: Fri, 12:20 pm
California: Fri, 11:20 am

Click here to visit Livelife365.com

Click here to visit nmdarts.com



Buy this Ad Space.

180px wide.

Please get in touch with KH@ if you are interested and make an offer.

CLICK HERE TO GET AUCTION BAR NOW
US$10 per year - Save $100s!
The Fabulously Unfair
WebX Auction Bar. For Ebay etc.
Ro-Sham-Bo the opposition. Laugh like Eric Cartman when you win! CLICK HERE NOW!


More information and sign-up.

WebXpertz Hosting.
Custom fit from $5pm. PHP/MySQL
You'll save money, we'll save money. Seems fair to me. Interested? If so Please PM me here and tell me what you need. Thanks!


Please click here for more information

For continued disscussion on this topic : Displaying ItemID instead of Title


Jordan
12-03-2004, 08:56 AM
Hi I'm new to CF and I downloaded a tutorial for a shopping cart.

When a user adds an item to the shopping cart the ItemID is displayed which means nothing to the user. Like I said, I'm really new to this and I can't figure out what exactly to change in the code to get it to display a meaniful title to the user rather than the ItemID.

In the Database ItemID is the Primary key and Album attribute I want to be displayed to the user.

Here is the code:

DisplayCart.cfm

<cfif IsDefined ('Session.Cart')>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="5" bgcolor="#FFFFFF">
<tr>
<td colspan="2"><hr></td>
</tr>
<tr align="center">
<td><strong>Now in your cart:</strong></td>
<td>&nbsp;</td>
</tr>
<tr align="center">
<td width="50%"><strong>
<cfloop from="1" to="#ArrayLen(Session.Cart.ItemID)#" index="ThisItem">
<cfoutput>
ItemID: #Session.Cart.ItemID[ThisItem]# | Quantity: #Session.Cart.Qty[ThisItem]# </cfoutput><br>
</cfloop>
</strong><br>
</td>
<td width="50%">[<a href="Checkout.cfm">Checkout</a>]</td>
</tr>
</table>
<hr>
</cfif>

Cart.cfm
<cfif IsDefined('FORM.Submit')>

<cflock timeout="5" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<!--- Check to see if a Cart Session exists, if it dosent create one. --->
<cfif IsDefined('Session.Cart') is "NO">
<cfscript>
Session.Cart=StructNew();
Session.Cart.ItemID=ArrayNew(1);
Session.Cart.Qty=ArrayNew(1);
</cfscript>
</cfif>
</cflock>

<!--- //If Item exists, Update Quantity // --->
<cfif ListFind(ArrayToList(Session.Cart.ItemID),FORM.ItemID) NEQ 0>

<cfset ThisItem=ListFind(ArrayToList(Session.Cart.ItemID),FORM.ItemID)>
<!--- //Set Quantity // --->
<cflock timeout="2" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<cfset Session.Cart.Qty[ThisItem]=Session.Cart.Qty[ThisItem] + FORM.Qty>
</cflock>

<cfelse>
<!--- If the Item doesn’t exist in the Cart Session, add it. --->
<cfset ThisItem=ArrayLen(Session.Cart.ItemID) +1 >
<!--- === [ Add to cart ] === // --->
<cflock timeout="5" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<cfset Session.Cart.ItemID[ThisItem]=FORM.ItemID>
<cfset Session.Cart.Qty[ThisItem]=FORM.Qty>
</cflock>

</cfif>

</cfif>


Thanks to anyone who can help me!

rnk
12-09-2004, 02:03 PM
You will need to ad the Title to the cart.

<cfset Session.Cart.ItemTitle[ThisItem]=FORM.ItemTitle>

Then on your form you will need to add a title to each item in a hidden field and display this to the user.
<cfoutput>
Item: #Session.Cart.ItemID[ThisItem]# - #Session.Cart.ItemTitle[ThisItem]# | Quantity: #Session.Cart.Qty[ThisItem]#
</cfoutput>


RnK