home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Examples / store / _showcart.cfm next >
Encoding:
Text File  |  1999-04-12  |  4.2 KB  |  115 lines

  1. <!--- This template is used by other templates via CFINCLUDE; it
  2.       is used to display the contents of the shopping cart in a
  3.       small table (a less detailed view than _showitems.cfm). --->
  4.  
  5. <!--- Don't let the browser cache this page. Otherwise we might
  6.       be looking at a cached shopping cart which does not reflect
  7.       what is truly in the cart. --->
  8. <CFHEADER Name="Expires" Value="#Now()#">
  9. <CFHEADER NAME="pragma" VALUE="no-cache">
  10.  
  11. <CFQUERY DATASOURCE="CFexamples" NAME="GetCategories">
  12. SELECT * FROM StoreCategories
  13. </CFQUERY>
  14.  
  15. <STYLE TYPE="text/css">
  16. #floater {
  17.     position: absolute;
  18.     left: 15;
  19.     top: 150;
  20.     width: 125;
  21.     visibility: visible;
  22.     z-index: 10;
  23. }
  24. </STYLE>
  25.  
  26. <DIV ID="floater">
  27.  
  28. <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
  29. <TR>
  30.     <TD><IMG SRC="images/widget_top.gif" WIDTH=122 HEIGHT=26 BORDER=0></TD>
  31. </TR>
  32.  
  33. <FORM ACTION="results.cfm" METHOD="POST">
  34. <TR>
  35.     <TD BACKGROUND="images/widget_bg.gif" BGCOLOR="#CC9933"><NOBR>  <FONT SIZE="-1"><INPUT TYPE="TEXT" NAME="Keyword" SIZE="10"></FONT> <INPUT TYPE="IMAGE" SRC="images/widget_go.gif" ALIGN="MIDDLE" BORDER=0></NOBR></TD>
  36. </TR>
  37. </FORM>
  38.  
  39. <TR>
  40.     <TD><IMG SRC="images/widget_divider.gif" WIDTH=122 HEIGHT=10 BORDER=0></TD>
  41. </TR>
  42.  
  43. <!--- loop over categories --->
  44. <TR>
  45.     <TD BACKGROUND="images/widget_bg.gif"><NOBR>  <FONT FACE="MS Sans Serif, Helvetica" SIZE="-1" COLOR="#FFFFCC"><A HREF="showcategories.cfm"><IMG SRC="images/widget_click.gif" WIDTH=13 HEIGHT=16 BORDER=0 ALIGN="TOP"></A> Store Front</FONT></NOBR>
  46.     <CFOUTPUT QUERY="GetCategories"><BR><NOBR>  <FONT FACE="MS Sans Serif, Helvetica" SIZE="-1" COLOR="##FFFFCC"><A HREF="showitems.cfm?CategoryID=#CategoryID#"><IMG SRC="images/widget_click.gif" WIDTH=13 HEIGHT=16 BORDER=0 ALIGN="TOP"></A> #CategoryName#</FONT></NOBR></CFOUTPUT></TD>
  47. </TR>
  48.  
  49. <TR>
  50.     <TD><IMG SRC="images/widget_divider.gif" WIDTH=122 HEIGHT=10 BORDER=0></TD>
  51. </TR>
  52. <TR>
  53.     <TD><IMG SRC="images/widget_inthebag.gif" WIDTH=122 HEIGHT=21 BORDER=0></TD>
  54. </TR>
  55. <TR>
  56.     <TD BACKGROUND="images/widget_bg2.gif" ALIGN="RIGHT">
  57.     <FONT FACE="MS Sans Serif, Helvetica" SIZE="1" COLOR="#00FF00">
  58.     <CFIF ListLen(Session.StoreItems) IS 0>
  59.          <NOBR>(empty cart)     </NOBR>
  60.     <CFELSE>
  61.         <!--- Initialize total cost variable --->
  62.         <CFSET TotalCost = 0>
  63.         
  64.         <!--- Loop over the list of items in the shopping cart --->
  65.         <CFLOOP INDEX="CurrIndex" FROM="1" TO="#ListLen(Session.StoreItems)#">
  66.     
  67.             <!--- Fetch the actual item ID and quantities for current item --->
  68.             <CFSET CurrItemID = ListGetAt(Session.StoreItems, CurrIndex)>
  69.             <CFSET CurrQuant = ListGetAt(Session.StoreQuantities, CurrIndex)>
  70.     
  71.             <!--- Find out what the current item is called --->    
  72.             <CFQUERY DATASOURCE="CFexamples" NAME="GetItem">
  73.                 SELECT ItemName, ItemPrice FROM StoreItems
  74.                 WHERE ItemID = #CurrItemID#
  75.             </CFQUERY>
  76.         
  77.             <!--- Display quantity and item name --->
  78.             <CFOUTPUT QUERY="GetItem">
  79.                 <NOBR>#CurrQuant# x #ItemName#     </NOBR><BR>
  80.             </CFOUTPUT>
  81.         
  82.             <!--- Add total value of current item to total cost variable --->
  83.             <CFSET TotalCost = TotalCost + CurrQuant * GetItem.ItemPrice>
  84.         
  85.         </CFLOOP>
  86.         
  87.         <NOBR>Total: <CFOUTPUT>#DollarFormat(TotalCost)#</CFOUTPUT>     </NOBR>
  88.  
  89.     </CFIF>
  90.     </FONT>
  91.     </TD>
  92. </TR>
  93. <TR>
  94.     <TD><IMG SRC="images/widget_midbottom.gif" WIDTH=122 HEIGHT=7 BORDER=0></TD>
  95. </TR>
  96. <TR>
  97.     <TD BACKGROUND="images/widget_bg.gif"><NOBR>  <FONT FACE="MS Sans Serif, Helvetica" SIZE="-1" COLOR="#FFFFCC"><A HREF="viewcart.cfm"><IMG SRC="images/widget_click.gif" WIDTH=13 HEIGHT=16 BORDER=0 ALIGN="TOP"></A> Details</FONT></NOBR><BR>
  98.     <NOBR>  <FONT FACE="MS Sans Serif, Helvetica" SIZE="-1" COLOR="#FFFFCC"><A HREF="checkout.cfm"><IMG SRC="images/widget_click.gif" WIDTH=13 HEIGHT=16 BORDER=0 ALIGN="TOP"></A> Checkout</FONT></NOBR></TD>
  99. </TR>
  100. <TR>
  101.     <TD><IMG SRC="images/widget_bottom.gif" WIDTH=122 HEIGHT=8 BORDER=0></TD>
  102. </TR>
  103. </TABLE>
  104.  
  105.  
  106. </DIV>
  107.  
  108. <CF_STALKER STYLE="floater">
  109.  
  110. <!---
  111. The Allaire example app task force (Cheng, Reiber, Gilson) is very grateful 
  112. to Spotted Antelope, Inc. for permission to use the stalker.cfm custom tag.
  113.  
  114. Find Spotted Antelope at http://www.spottedantelope.com 
  115. --->