check_out.asp
None.
Include Files
- /advworks/Cart.inc (1)
- /advworks/Disclaim.inc (1)
- /advworks/srcform.inc (1)
Session Variables Set
- CustomerID (1)
- ItemCount (3)
- MyShoppingCart (4)
Session Variables Used
- ConnectionString (2)
- CustomerFirstName (1)
- CustomerID (3)
- ItemCount (5)
- MyShoppingCart (6)
Redirections
- RESPONSE-REDIRECT > /advworks/Equipment/GetCustomer.asp (1)
- RESPONSE-REDIRECT > /advworks/equipment/default.asp (2)
Images Used
Tlc 252
252
Source
<!--#include virtual="/advworks/Cart.inc"-->
<%
iCount = Session("ItemCount")
ARYshoppingcart = Session("MyShoppingCart")
Set Conn = Server.CreateObject("ADODB.Connection")
If Request.QueryString("ProductCode") <> "" Then
If iCount < MaxShoppingCartItems Then
iCount = iCount + 1
End if
Session("ItemCount") = iCount
Conn.Open Session("ConnectionString")
SQLcatalog_item = "SELECT ProductID, ProductCode, ProductName, ProductDescription, UnitPrice, OnSale FROM Products WHERE {fn UCASE(ProductCode)} = '" & Ucase(Request.QueryString("ProductCode")) & "'"
Set RS = Conn.Execute(SQLcatalog_item)
If Not IsEmpty(RS) Then
ARYshoppingcart(cartCHECKED,iCount) = "CHECKED"
ARYshoppingcart(cartProductCode,iCount) = RS("ProductCode")
ARYshoppingcart(cartProductName,iCount) = RS("ProductName")
ARYshoppingcart(cartProductDescription,iCount) = RS("ProductDescription")
ARYshoppingcart(cartItemQuantity,iCount) = 1
If RS("OnSale") Then
ARYshoppingcart(cartUnitPrice,iCount) = RS("UnitPrice") - (RS("UnitPrice") * 0.1)
Else
ARYshoppingcart(cartUnitPrice,iCount) = RS("UnitPrice")
End If
ARYshoppingcart(cartProductID,iCount) = RS("ProductID")
Session("MyShoppingCart") = ARYshoppingcart
RS.Close
Conn.Close
End If
End If
SELECT CASE Request("Action")
CASE "Shop for More"
For i = 1 to iCount
Quantity = Request("Quantity" & CStr(i))
If IsNumeric(Quantity) Then
ARYshoppingcart(cartItemQuantity,i) = abs(CLng(Quantity))
Else
ARYshoppingcart(cartItemQuantity,i) = 1
End If
Next
Session("MyShoppingCart") = ARYshoppingcart
Response.Redirect "/advworks/equipment/default.asp"
CASE "Recalculate"
For i = 1 to iCount
Quantity = Request("Quantity" & CStr(i))
If IsNumeric(Quantity) Then
ARYshoppingcart(cartItemQuantity,i) = abs(CLng(Quantity))
Else
ARYshoppingcart(cartItemQuantity,i) = 1
End If
Next
For i = 1 to iCount
If Request("Confirm" & CStr(i)) = "" Then
iCount = iCount - 1
For x = 1 to UBound(ARYshoppingcart,1)
ARYshoppingcart(x,i) = ""
Next
n = i
while n < UBound(ARYshoppingcart,2)
For x = 1 to UBound(ARYshoppingcart,1)
ARYshoppingcart(x,n) = ARYshoppingcart(x,n + 1)
ARYshoppingcart(x,n + 1) = ""
Next
n = n + 1
wend
End If
Next
Session("MyShoppingCart") = ARYshoppingcart
Session("ItemCount") = iCount
CASE "Cancel Order"
iCount = 0
Session("ItemCount") = iCount
Response.Redirect "/advworks/equipment/default.asp"
CASE "Click to Pay"
Quantity = Request("Quantity" & CStr(i))
If IsNumeric(Quantity) Then
ARYshoppingcart(cartItemQuantity,i) = abs(CLng(Quantity))
Else
ARYshoppingcart(cartItemQuantity,i) = 1
End If
Session("MyShoppingCart") = ARYshoppingcart
' Check if new customer
CustomerID = Session("CustomerID")
if CustomerID = 0 then ' new customer
Response.Redirect "/advworks/Equipment/GetCustomer.asp"
else
' First check to ensure that the customer was not removed from the database
Conn.Open Session("ConnectionString")
Set rs = Conn.Execute( _
"select CompanyName FROM Customers where CustomerID = " & CustomerID & _
" and ContactFirstName = '" & Session("CustomerFirstName") & "'")
URL = "/advworks/equipment/shipping.asp"
If rs.EOF Then
Session("CustomerID") = -1 ' This means the user WAS in the database at one time, but isn't now
URL ="/advworks/Equipment/GetCustomer.asp"
End If
rs.Close
Conn.Close
Response.Redirect URL
End If
END SELECT
%>
<html>
<head>
<title>Adventure Works - Shopping Cart</title>
</head>
<body BACKGROUND="images/back_sub.gif" LINK="#800000" VLINK="#008040">
<font FACE="Verdana, Arial, Helvetica" SIZE="2">
<table BORDER="0">
<tr>
<td WIDTH="30">
<img SRC="images/spacer.gif" ALIGN="RIGHT" ALT WIDTH="100" HEIGHT="10">
</td>
<td COLSPAN="5">
<img SRC="images/hd_Check_out.gif" width="250" height="42" ALT="Check Out">
<hr SIZE="4">
</td>
</tr>
<!-- BEGIN Navigational buttons -->
<tr>
<td ROWSPAN="20" ALIGN="LEFT" VALIGN="TOP">
<img SRC="images/spacer.gif" WIDTH="120" ALT>
</td>
<td>
<!-- BEGIN table inserted into table data cell --><!-- BEGIN form with first row of data -->
<form ACTION="/advworks/equipment/check_out.asp?" METHOD="POST">
<table COLSPAN="8" CELLPADDING="5" BORDER="0">
<!-- BEGIN column header row -->
<tr>
<td ALIGN="CENTER" BGCOLOR="#800000">
<font STYLE="Verdana, Arial, Helvetica" COLOR="#ffffff" SIZE="2">Confirm</font>
</td>
<td ALIGN="CENTER" BGCOLOR="#800000">
<font STYLE="Verdana, Arial, Helvetica" COLOR="#ffffff" SIZE="2">Product Code</font>
</td>
<td ALIGN="CENTER" BGCOLOR="#800000">
<font STYLE="Verdana, Arial, Helvetica" COLOR="#ffffff" SIZE="2">Product Name</font>
</td>
<td ALIGN="CENTER" WIDTH="150" BGCOLOR="#800000">
<font STYLE="Verdana, Arial, Helvetica" COLOR="#ffffff" SIZE="2">Description</font>
</td>
<td ALIGN="CENTER" BGCOLOR="#800000">
<font STYLE="Verdana, Arial, Helvetica" COLOR="#ffffff" SIZE="2">Quantity</font>
</td>
<td ALIGN="CENTER" BGCOLOR="#800000">
<font STYLE="Verdana, Arial, Helvetica" COLOR="#ffffff" SIZE="2">Unit Price</font>
</td>
<td ALIGN="CENTER" BGCOLOR="#800000">
<font STYLE="Verdana, Arial, Helvetica" COLOR="#ffffff" SIZE="2">Unit Total</font>
</td>
</tr>
<%
iSubtotal = 0
For i = 1 to iCount
%>
<!-- BEGIN first row of inserted product data -->
<tr>
<td ALIGN="CENTER" BGCOLOR="f7efde">
<%If ARYshoppingcart(cartCHECKED,i) = "CHECKED" Then%>
<input TYPE="CHECKBOX" NAME="<%Response.Write "Confirm" & CStr(i)%>" VALUE="Confirmed" CHECKED> <%End If%>
</td>
<td BGCOLOR="f7efde" ALIGN="CENTER">
<font STYLE="Verdana, Arial, Helvetica" SIZE="2"><%=ARYshoppingcart(cartProductCode,i)%></font>
</td>
<td BGCOLOR="f7efde" ALIGN="CENTER">
<font STYLE="Verdana, Arial, Helvetica" SIZE="2"><%=ARYshoppingcart(cartProductName,i)%></font>
</td>
<td BGCOLOR="f7efde" ALIGN="LEFT" WIDTH="150">
<font STYLE="Verdana, Arial, Helvetica" SIZE="2"><%=ARYshoppingcart(cartProductDescription,i)%></font>
</td>
<td BGCOLOR="f7efde" ALIGN="CENTER">
<%If ARYshoppingcart(cartCHECKED,i) = "CHECKED" Then%>
<font STYLE="Verdana, Arial, Helvetica" SIZE="2"><input TYPE="TEXT" NAME="<%Response.Write "Quantity" & CStr(i)%>" VALUE="<%=ARYshoppingcart(cartItemQuantity,i)%>" SIZE="2" MAXLENGTH="5"></font>
<%End If%>
</td>
<td BGCOLOR="f7efde" ALIGN="RIGHT">
<font STYLE="Verdana, Arial, Helvetica" SIZE="2"><% = FormatCurrency(ARYshoppingcart(cartUnitPrice,i))%></font>
</td>
<td BGCOLOR="f7efde" ALIGN="RIGHT">
<font STYLE="Verdana, Arial, Helvetica" SIZE="2"><% = FormatCurrency(ARYshoppingcart(cartUnitPrice,i) * ARYshoppingcart(cartItemQuantity,i))%></font>
</td>
</tr>
<%
If (ARYshoppingcart(cartUnitPrice,i)) <> "" Then
iSubTotal = iSubtotal + (ARYshoppingcart(cartUnitPrice,i) * ARYshoppingcart(cartItemQuantity,i))
End If
Next
%>
<!-- BEGIN subtotal -->
<tr>
<td COLSPAN="5"></td>
<td BGCOLOR="f7efde" ALIGN="LEFT"><font STYLE="Verdana, Arial, Helvetica" COLOR="#800000" SIZE="2">Subtotal:</font></td>
<td BGCOLOR="f7efde" ALIGN="RIGHT"><font STYLE="Verdana, Arial, Helvetica" SIZE="2"><% = FormatCurrency(iSubtotal)%></font></td>
</tr>
<tr>
<td ALIGN="RIGHT" COLSPAN="3"></td>
<td COLSPAN="5" ALIGN="RIGHT">
<% If iCount < MaxShoppingCartItems Then %>
<input TYPE="SUBMIT" NAME="Action" VALUE="Shop for More">
<% End If %>
<% If iCount > 0 Then %>
<input TYPE="SUBMIT" NAME="Action" VALUE="Click to Pay">
<input TYPE="SUBMIT" NAME="Action" VALUE="Recalculate">
<% End If %>
<input TYPE="SUBMIT" NAME="Action" VALUE="Cancel Order">
</td>
</tr>
</table>
</form>
<!-- END table inserted into table data cell -->
</td>
<% REM Column Span Value %>
<% HTML_CS = 5 %>
<% HTML_INDENT = FALSE %>
<!--#include virtual="/advworks/Disclaim.inc"-->
<!--#include virtual="/advworks/srcform.inc"-->
</table>
</body>
</html>