home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Examples / store / _showitems.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  4.6 KB  |  127 lines

  1. <!--- This template is used by other templates via CFINCLUDE; for
  2.       example, after additem.cfm is used to add an item to the shopping
  3.       cart, _showcart.cfm is CFINCLUDE-ed to show the result contents
  4.       of the shopping cart. --->
  5.  
  6. <!--- Don't let the browser cache this page. Otherwise we might
  7.       be looking at a cached shopping cart which does not reflect
  8.       what is truly in the cart. --->
  9. <CFHEADER Name="Expires" Value="#Now()#">
  10. <CFHEADER NAME="pragma" VALUE="no-cache">
  11.  
  12. <!--- If there are 0 of any item, remove that item from the cart --->
  13. <CFSET LoopVar = 1>
  14. <CFLOOP CONDITION="LoopVar LTE ListLen(Session.StoreItems)">
  15.     <CFIF ListGetAt(Session.StoreQuantities, LoopVar) LT 1>
  16.         <CFSET Session.StoreQuantities = ListDeleteAt(Session.StoreQuantities, LoopVar)>
  17.         <CFSET Session.StoreItems = ListDeleteAt(Session.StoreItems, LoopVar)>
  18.     <CFELSE>
  19.         <CFSET LoopVar = LoopVar + 1>
  20.     </CFIF>
  21. </CFLOOP>
  22.  
  23.  
  24. <FONT FACE=" arial black,Helvetica bold,geneva,helvetica" SIZE="7" COLOR="##000000"><I>Bag It!</i></FONT><br>
  25. <br>
  26.  
  27. <TABLE BORDER="0" CELLPADDING="5" CELLSPACING="1" bgcolor="000000">
  28.  
  29. <!--- These are just the column headings --->
  30. <TR>
  31.     <TD BGCOLOR="#660000"><FONT FACE="Helvetica" SIZE="-1" COLOR="#FFFF00"><B>Item #</B></TD>
  32.     <TD BGCOLOR="#660000"><FONT FACE="Helvetica" SIZE="-1" COLOR="#FFFF00"><B>Description</B></TD>
  33.     <TD BGCOLOR="#660000"><FONT FACE="Helvetica" SIZE="-1" COLOR="#FFFF00"><B>Unit Price</B></TD>
  34.     <TD BGCOLOR="#660000"><FONT FACE="Helvetica" SIZE="-1" COLOR="#FFFF00"><B>Quantity</B></TD>
  35.     <TD BGCOLOR="#660000"><FONT FACE="Helvetica" SIZE="-1" COLOR="#FFFF00"><B>Subtotal</B></TD>
  36. </TR>
  37.  
  38.  
  39. <!--- If the shopping cart is empty, just say that. --->
  40. <CFIF Session.StoreItems IS "">
  41.  
  42.     <TR>
  43.         <TD BGCOLOR="#FFcc66" COLSPAN="5" ALIGN="CENTER">
  44.         <FONT FACE="Helvetica" SIZE="-1"><I>(There are currently no items in your
  45.         shopping cart.)</I></FONT>
  46.         </TD>
  47.     </TR>
  48.  
  49. <!--- On the other hand, if the cart is not empty... --->
  50. <CFELSE>
  51.  
  52.     <!--- This form is called if quantities of the items are changed --->
  53.     <FORM ACTION="changequants.cfm" METHOD="POST">
  54.     <CFOUTPUT>
  55.     <INPUT TYPE="HIDDEN" NAME="StoreItems" VALUE="#Session.StoreItems#">
  56.     <INPUT TYPE="HIDDEN" NAME="StoreQuantities" VALUE="#Session.StoreQuantities#">
  57.     </CFOUTPUT>
  58.     
  59.     <!--- This variable will be used to accumulate the total cost --->
  60.     <CFSET TotalCost = 0>
  61.  
  62.     <!--- Loop over the list of items in the shopping cart --->
  63.     <CFLOOP LIST="#Session.StoreItems#" INDEX="CurrentItemID">
  64.     
  65.         <!--- Find the quantity of each item --->
  66.         <CFSET ItemPosition = ListFind(Session.StoreItems, CurrentItemID)>
  67.         <CFSET Quantity = ListGetAt(Session.StoreQuantities, ItemPosition)>
  68.  
  69.         <!--- This query is just to get the name and price of the current
  70.               item so that we can display that data in the table --->
  71.         <CFQUERY DATASOURCE="CFexamples" NAME="GetCurrentItem">
  72.             SELECT ItemID, PartNum, ItemName, ItemPrice FROM StoreItems
  73.             WHERE ItemID = #CurrentItemID#
  74.         </CFQUERY>
  75.  
  76.         <!--- Now display the data for the current item --->
  77.         <CFOUTPUT QUERY="GetCurrentItem">
  78.         <TR>
  79.             <TD BGCOLOR="##FFff99"><FONT FACE="Helvetica" SIZE="-1">#PartNum#</TD>
  80.             <TD BGCOLOR="##FFff99"><FONT FACE="Helvetica" SIZE="-1">#ItemName#</TD>
  81.             <TD BGCOLOR="##FFff99"><FONT FACE="Helvetica" SIZE="-1">#DollarFormat(ItemPrice)#</TD>
  82.             <TD BGCOLOR="##FFff99"><FONT FACE="Helvetica">
  83.                 <INPUT TYPE="TEXT" NAME="Item#ItemID#" SIZE="3" VALUE="#Variables.Quantity#">
  84.             </TD>
  85.             <TD BGCOLOR="##FFff99" ALIGN="RIGHT"><FONT FACE="Helvetica" SIZE="-1">
  86.                 #DollarFormat(ItemPrice * Variables.Quantity)#
  87.             </TD>
  88.         </TR>
  89.         </CFOUTPUT>
  90.  
  91.         <!--- Add cost of current item(s) to total cost --->
  92.         <CFSET TotalCost = TotalCost + GetCurrentItem.ItemPrice * Variables.Quantity>
  93.  
  94.     </CFLOOP>
  95.  
  96.     <TR>
  97.         <TD COLSPAN="4" BGCOLOR="#FFff99" ALIGN="RIGHT">
  98.             <FONT FACE="Helvetica" SIZE="-1"><B>Total</B></FONT>
  99.         </TD>
  100.         <TD BGCOLOR="#FFff99" ALIGN="RIGHT">
  101.             <!--- Display the total cost --->
  102.             <CFOUTPUT>
  103.             <FONT FACE="Helvetica" SIZE="-1">#DollarFormat(TotalCost)#</FONT>
  104.             </CFOUTPUT>
  105.         </TD>
  106.     </TR>
  107. </TABLE>
  108. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=382>
  109.     <TR>
  110.         <TD><BR><INPUT TYPE="SUBMIT" VALUE="Change Quantities"></TD>
  111.         <TD ALIGN="RIGHT"><BR><INPUT TYPE="BUTTON" VALUE="Checkout" onClick="location.href = 'checkout.cfm'"></TD>
  112.     </TR>
  113.     
  114.     </FORM>
  115.  
  116. </CFIF>
  117.  
  118. </TABLE>
  119.  
  120. <BR>
  121.  
  122. <FONT FACE="Helvetica" SIZE="-1">
  123. <CFOUTPUT>
  124.     <A HREF="showcategories.cfm">Return to Category Listing</A><BR>
  125.     <CFIF IsDefined("Session.LastCategory")><A HREF="showitems.cfm?CategoryID=#Session.LastCategory#">Return to Last Category</A></CFIF>
  126. </CFOUTPUT>
  127. </FONT>