%
Option Explicit
Response.Buffer=True
Const vDebug = 0
%>
<%
'@BEGINVERSIONINFO
'@APPVERSION: 5.10.00
'@FILENAME: order.asp
'@FILEVERSION: 1.0.0
'@VERSIONDATETIME: 1/26/01
'@DESCRIPTION: Cart Page
'@STARTCOPYRIGHT
'The contents of this file is protected under the United States
'copyright laws as an unpublished work, and is confidential and proprietary to
'LaGarde, Incorporated. Its use or disclosure in whole or in part without the
'expressed written permission of LaGarde, Incorporated is expressly prohibited.
'
'(c) Copyright 2000 by LaGarde, Incorporated. All rights reserved.
'@ENDCOPYRIGHT
'@ENDVERSIONINFO
If iConverion = 1 Then Response.Write ""
Dim CurrencyISO
CurrencyISO = getCurrencyISO(Session.LCID )
%>
SF Shopping Cart Page/Begin Checkout Page
<%If C_BNRBKGRND = "" Then%>
<%= C_STORENAME %>
<%Else%>
<%End If%>
Order
Summary
Please review your order as shown below. To modify the quantity of any item ordered,
input the desired quantity and select the Recalculate Order
button below. To delete an item click on DELETE. To save
an item to return and purchase at a later time click on SAVE.
If you want to add new items return to the correct page and select additional items to be added to your order. When you have
completed your order, select the Check Out button below to connect to our secure directory and complete the order process.
product
unit price
qty
price
action
<%
'@BEGINCODE
Dim sSql, rsAllOrders, sProdID, aProduct, aProdAttr, sProdName, sProdPrice, iProdAttrNum, iCounter
Dim sAttrUnitPrice, sUnitPrice, iQuantity, iNewQuantity, sProductSubtotal, dProductSubtotal, dTotalPrice, iOrderID, aProdAttrID, sTotalPrice, sProductPrice
Dim iProductCounter, sBgColor, sFontFace, sFontColor, iFontSize
Dim bHasProducts, sBtnAction, sSaveCart, sDelete, iSvdCartID,iCustID, sRecalculate, iSaveFind, iDeleteFind
Dim sErrorDescription, sSearchPath, sBkGrnd, sReferer
' Determine action and OrderID
For iCounter = 1 to Request.Form("iProductCounter")
sSaveCart = Request.Form("SaveToCart" & iCounter & ".x")
If sSaveCart <> "" Then
iSaveFind = iCounter
sBtnAction = "SaveToCart"
Exit For
End If
sDelete = Request.Form("DeleteFromOrder" & iCounter & ".x")
If sDelete <> "" Then
iDeleteFind = iCounter
sBtnAction = "DeleteFromCart"
Exit For
End If
Next
' Check to see if custID exists in customer table
iCustID = Request.Cookies("sfCustomer")("custID")
If iCustID <> "" Then
Dim bCustIdExists
bCustIdExists = CheckCustomerExists(iCustID)
If bCustIdExists = false Then
Response.Cookies("sfCustomer")("custID") = ""
Response.Cookies("sfCustomer").Expires = NOW()
End If
End If
' Determine if it is recalculate action
sRecalculate = Request.Form("Recalculate.x")
If sRecalculate <> "" Then
sBtnAction = "Recalculate"
End If
' Get referer
sReferer = Session("HttpReferer")
' Recalculate subtotal
If sBtnAction = "Recalculate" Then
Dim iTmpOrderID, iOldQuantity
For iCounter = 1 To Request.Form("iProductCounter")
iNewQuantity = Request.Form("FormQuantity" & iCounter)
iOldQuantity = Request.Form("iQuantity" & iCounter)
iTmpOrderID = Request.Form("iOrderID" & iCounter)
If iNewQuantity <> "" Then
If iNewQuantity = 0 Then
' Delete if 0
Call setDeleteOrder("odrdttmp",iTmpOrderID)
ElseIf iNewQuantity <> iOldQuantity Then
' Update Quantity For Product
Call setReplaceQuantity("odrdttmp",iNewQuantity,iTmpOrderID)
End If
Else
' Delete if Null Value
Call setDeleteOrder("odrdttmp",iTmpOrderID)
End If
Next
' Save to Cart
ElseIf sBtnAction = "SaveToCart" Then
sProdID = Request.Form("sProdID" & iSaveFind)
iOrderID = Request.Form("iOrderID" & iSaveFind)
iQuantity = Request.Form("iQuantity" & iSaveFind)
iProdAttrNum = Request.Form("iProdAttrNum" & iSaveFind)
iCustID = Request.Cookies("sfCustomer")("custID")
iNewQuantity = Request.Form("FormQuantity" & iSaveFind)
' In the case that one types in a new quantity and hits save
If iNewQuantity <> iQuantity And iNewQuantity <> "" And iNewQuantity <> 0 Then
iQuantity = iNewQuantity
End If
If iProdAttrNum > 0 Then
Redim aProdAttr(iProdAttrNum)
aProdAttr = getProdAttr("odrattrtmp",iOrderID,iProdAttrNum)
End If
' Check if cookies are set
If Request.Cookies("sfCustomer")("custID") = "" OR Request.Cookies("sfOrder")("SessionID") <> Session("SessionID") Then
' Write to cookie identifying place
Call getSavedTable(aProdAttr,sProdID,iNewQuantity,0,sReferer)
Response.Cookies("sfThanks")("PreviousAction") = "FromShopCart"
Response.Cookies("sfThanks")("DeleteTmpOrderID") = iOrderID
Response.Cookies("sfThanks").Expires = Date() + 1
Response.Redirect("login.asp")
End If
If iProdAttrNum > 0 Then
Redim aProdAttr(iProdAttrNum)
aProdAttr = getProdAttr("odrattrtmp",iOrderID,iProdAttrNum)
End If
iSvdCartID = getOrderID("odrdtsvd","odrattrsvd", sProdID,aProdAttr,cInt(iProdAttrNum))
If iSvdCartID <> "" Then
' New Row in SavedCartDetails
If iSvdCartID < 0 Then
' Write as new row
Call getSavedTable(aProdAttr,sProdID,iQuantity,iCustID,Session("HttpReferer"))
' Existing cart
Else
' Update Quantity
Call setUpdateQuantity("odrdtsvd",iQuantity,iSvdCartID)
' End iSvdCartID exists If
End If
Else
'sErrorDescription = "Number of attributes not equal to the product specs or database writing error."
'Response.Redirect("error.asp?strPageName=order.asp&strErrorDescription="&sErrorDescription)
' End iSvdCartID Null If
End If
' delete from sfTmpOrderDetails
Call setDeleteOrder("odrdttmp",iOrderID)
ElseIf sBtnAction = "DeleteFromCart" Then
' Remove from cart
iOrderID = Request.Form("iOrderID" & iDeleteFind)
Call setDeleteOrder("odrdttmp",iOrderID)
End If
' Product counter initialize
iProductCounter = 0
dTotalPrice = 0
'-----------------------------------------------------------------
' Collect all orders associated with Session ::: Begin
'-----------------------------------------------------------------
' Get a RecordSet of all orders
sSql = "SELECT * FROM sfTmpOrderDetails WHERE odrdttmpSessionID = " & Session("SessionID")
If vDebug = 1 Then Response.Write " " & sSql
Set rsAllOrders = cnn.execute(sSql)
' Check for no orders
If (rsAllOrders.BOF And rsAllOrders.EOF) Then
bHasProducts = False
%>
No Items in Order
Please press continue to begin searching for items
<%
Else
bHasProducts = True
Do While NOT rsAllOrders.EOF
' Get the ProdIDs
iOrderID = rsAllOrders.Fields("odrdttmpID")
sProdID = rsAllOrders.Fields("odrdttmpProductID")
iQuantity = rsAllOrders.Fields("odrdttmpQuantity")
' Get an array of 3 values from getProduct()
'++ On Error Resume Next
ReDim aProduct(3)
aProduct = getProduct(sProdID)
sProdName = aProduct(0)
sProdPrice = aProduct(1)
iProdAttrNum = aProduct(2)
' ++ Call CheckForError()
' If not an array, then the product does not exist
If NOT IsArray(aProduct) Then
Response.Write " Product Does Not Exist"
' ++ Needs to MoveNext to iterate through the rest of the order
Else
If NOT IsNumeric(iProdAttrNum)Then
iProdAttrNum = 0
End If
' Get Associated Attribute IDs in an array
If iProdAttrNum <> "" Then
ReDim aProdAttrID(iProdAttrNum)
aProdAttrID = getProdAttr("odrattrtmp",iOrderID,iProdAttrNum)
End If
' Response Write all Output
If vDebug = 1 And IsArray(aProdAttrID) Then
Response.Write "
Product = " & sProdID & " ProdName = " & sProdName & " ProdPrice = " & sProdPrice & " ProdAttrNum = " & iProdAttrNum
For iCounter = 0 To iProdAttrNum -1
Response.Write " Attribute :" & aProdAttrID(iCounter)
Next
End If
iProductCounter = iProductCounter + 1
' Do alternating colors and fonts
If (iProductCounter mod 2) = 1 Then
sBgColor = C_ALTBGCOLOR1
sBkGrnd = C_ALTBKGRND1
sFontFace = C_ALTFONTFACE1
sFontColor = C_ALTFONTCOLOR1
iFontSize = C_ALTFONTSIZE1
Else
sBgColor = C_ALTBGCOLOR2
sBkGrnd = C_ALTBKGRND2
sFontFace = C_ALTFONTFACE2
sFontColor = C_ALTFONTCOLOR2
iFontSize = C_ALTFONTSIZE2
End If
%>
<%= sProdName %>
<%
sAttrUnitPrice = 0
' Iterate Through Attributes
If iProdAttrNum > 0 And IsArray(aProdAttrID) Then
Dim sAttrSubtotal, aAttrDetails, sAttrName, sAttrPrice, iAttrType
For iCounter = 0 To iProdAttrNum - 1
aAttrDetails = getAttrDetails(aProdAttrID(iCounter))
sAttrName = aAttrDetails(0)
sAttrPrice = aAttrDetails(1)
iAttrType = aAttrDetails(2)
' Calculate Subtotal
sAttrUnitPrice = getAttrUnitPrice(sAttrUnitPrice,sAttrPrice,iAttrType)
%>
<%=sAttrName%>
<%
' ProdAttr Loop
Next
Elseif iProdAttrNum > 0 And NOT IsArray(aProdAttrID) Then
Response.Write " Error: No Attributes found for " & iOrderID
Response.Write " Deleting from Saved Orders. Sorry for the inconvenience."
Call setDeleteOrder("odrdttmp",iOrderID)
If vDebug = 1 Then Response.Write "
Deleted: " & iOrderID & ""
' End Product Attribute If
End If
' Set Unit Price for Product
If iConverion = 1 Then
sUnitPrice = ""
Else
sUnitPrice = FormatCurrency(cDbl(sAttrUnitPrice) + cDbl(sProdPrice))
End If
dProductSubtotal = iQuantity * (cDbl(sAttrUnitPrice) + cDbl(sProdPrice))
If dTotalPrice < 0 Then
dTotalPrice = "Error: Your SubTotal Was a Negative Amount"
Else
If iConverion = 1 Then
sProductSubtotal = ""
dTotalPrice = ""
Else
sProductSubtotal = FormatCurrency(dProductSubtotal)
dTotalPrice = dTotalPrice + cDbl(dProductSubtotal)
End If
End If
%>
<%
' End IsArray If
End If
' Move to next RecordSet
rsAllOrders.MoveNext
' loop through recordset
Loop
'@ENDCODE
'-----------------------------------------------------------
' END PRODUCT DETAIL OUTPUT --------------------------------
'-----------------------------------------------------------
%>