%@ Language=VBScript %>
<%
'*************************************************************************
' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK!
' Function : Display order details from customer's account
' Product : CandyPress Store Frontend
' Version : 2.5
' Modified : February 2004
' Copyright: Copyright (C) 2004 CandyPress.Com
' See "license.txt" for this product for details regarding
' licensing, usage, disclaimers, distribution and general
' copyright requirements. If you don't have a copy of this
' file, you may request one at webmaster@candypress.com
'*************************************************************************
Option explicit
Response.Buffer = true
%>
<%
'cartHead
dim randomKey
dim orderStatus
dim orderDate
dim subTotal
dim taxTotal
dim shipmentTotal
dim handlingFeeTotal
dim otherFeeTotal
dim Total
dim shipmentMethod
dim Name
dim LastName
dim CustomerCompany
dim Phone
dim Email
dim Address
dim City
dim Zip
dim locState
dim locCountry
dim shippingName
dim shippingLastName
dim shippingPhone
dim shippingAddress
dim ShippingCity
dim shippingZip
dim shippingLocState
dim shippingLocCountry
dim paymentType
dim cardType
dim cardNumber
dim cardExpMonth
dim cardExpYear
dim cardName
dim cardVerify
dim generalComments
dim storeComments
dim adjustReason
dim adjustAmount
dim discCode
dim discPerc
dim discTotal
dim storeCommentsPriv
'cartRows
dim IDCartRow
dim IDProduct
dim SKU
dim Quantity
dim unitPrice
dim Description
dim discAmt
'cartRowsOptions
dim idOption
dim optionPrice
dim optionDescrip
'Products
dim fileName
'DiscProd
dim idDiscProd
dim discFromQty
dim discToQty
'Work Fields
dim f
dim qIdOrder
dim optionGroupsTotal
dim optionsDisplay
dim refererURL
dim action
'Database
dim mySQL
dim conntemp
dim rstemp
dim rstemp2
'Session
dim idOrder
dim idCust
'*************************************************************************
'Open Database Connection
call openDb()
'Store Configuration
if loadConfig() = false then
call errorDB(langErrConfig,"")
end if
'Get/Set Cart/Order Session
idOrder = sessionCart()
'Get/Set Customer Session
idCust = sessionCust()
'Check that the Customer logged in
if isNull(idCust) then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrNotLoggedIn)
end if
'Validate Order Number from QueryString
qIdOrder = Request.QueryString("idOrder")
if len(qIdOrder) = 0 or not IsNumeric(qIdOrder) then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrInvOrder)
end if
'Retrieve some information we need from cartHead
mySQL="SELECT randomKey,orderStatus,orderDate,subTotal,taxTotal," _
& " shipmentTotal,Total,shipmentMethod,Name,LastName," _
& " CustomerCompany,Phone,Email,Address,City,locState," _
& " locCountry,Zip,shippingName,shippingLastName,shippingPhone," _
& " shippingAddress,ShippingCity,shippingLocState," _
& " shippingLocCountry,shippingZip,paymentType,cardType," _
& " cardNumber,cardExpMonth,cardExpYear,cardVerify," _
& " cardName,generalComments,adjustReason,adjustAmount," _
& " discCode,discPerc,discTotal,handlingFeeTotal,otherFeeTotal," _
& " storeComments,storeCommentsPriv " _
& "FROM cartHead " _
& "WHERE idOrder = " & validSQL(qIdOrder,"I") & " " _
& "AND idCust = " & validSQL(idCust,"I")
set rsTemp = openRSexecute(mySQL)
if not rstemp.eof then
'Assign to local variables
storeComments = rstemp("storeComments")
randomKey = rstemp("randomKey")
orderStatus = rstemp("orderStatus")
orderDate = rstemp("orderDate")
subTotal = rstemp("subTotal")
taxTotal = rstemp("taxTotal")
shipmentTotal = rstemp("shipmentTotal")
Total = rstemp("Total")
shipmentMethod = rstemp("shipmentMethod")
Name = rstemp("name")
LastName = rstemp("LastName")
CustomerCompany = rstemp("CustomerCompany")
Phone = rstemp("Phone")
Email = rstemp("Email")
Address = rstemp("Address")
City = rstemp("City")
Zip = rstemp("Zip")
locState = rstemp("locState")
locCountry = rstemp("locCountry")
shippingName = rstemp("shippingName")
shippingLastName = rstemp("shippingLastName")
shippingPhone = rstemp("shippingPhone")
shippingAddress = rstemp("shippingAddress")
ShippingCity = rstemp("ShippingCity")
shippingZip = rstemp("shippingZip")
shippingLocState = rstemp("shippingLocState")
shippingLocCountry = rstemp("shippingLocCountry")
paymentType = rstemp("paymentType")
cardType = rstemp("cardType")
cardNumber = rstemp("cardNumber")
cardExpMonth = rstemp("cardExpMonth")
cardExpYear = rstemp("cardExpYear")
cardName = rstemp("cardName")
cardVerify = rstemp("cardVerify")
generalComments = rstemp("generalComments")
adjustReason = rstemp("adjustReason")
adjustAmount = rstemp("adjustAmount")
discCode = rstemp("discCode")
discPerc = rstemp("discPerc")
discTotal = rstemp("discTotal")
handlingFeeTotal = rstemp("handlingFeeTotal")
otherFeeTotal = rstemp("otherFeeTotal")
storeCommentsPriv = rstemp("storeCommentsPriv")
'Decrypt Card Number (if required)
cardNumber = EnDeCrypt(Hex2Ascii(cardNumber),rc4Key)
'Cater for orders entered before order discounts were added
if isNull(discPerc) then
discPerc = 0.00
end if
if isNull(discTotal) then
discTotal = 0.00
end if
else
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrInvOrder)
end if
call closeRS(rsTemp)
'What page did we come from?
refererURL = lCase(Request.ServerVariables("HTTP_REFERER"))
'Check if we are showing the 'print' version of the page
action = trim(Request.QueryString("action"))
if lCase(action) <> "print" then
action = ""
end if
'If we are printing this page display different header
if action = "print" then
%>
Invoice
<%
cartMain()
%>
<%
else
%>
<%
end if
'Close Database Connection
call closeDB()
'**********************************************************************
'Main Shopping Cart Display Area.
'**********************************************************************
sub cartMain()
%>
<%
if action <> "print" then
call pageHeading()
call defaultLinks()
call pendingMessage()
end if
%>
| <%=langGenOrderNumber%> |
<%=pOrderPrefix & "-" & qIdOrder%> |
| <%=langGenOrderDate%> |
<%=formatTheDate(orderDate)%> |
| <%=langGenOrderStatus%> |
<%=orderStatusDesc(orderStatus)%> |
| <%=langGenStoreComments%> |
<%=replace(emptyString(storeComments,"None"),Chr(10)," ")%> |
| <%=langGenEmail%> |
<%=email%> |
<%call drawHLine()%>
| |
<%=langGenBillAddr%> |
<%=langGenShipAddr%> |
| <%=langGenFullName%> |
<%=Name & " " & LastName%> |
<%=emptyString(shippingName,Name) & " " & emptyString(shippingLastName,LastName)%> |
| <%=langGenAddress%> |
<%=address%> |
<%=emptyString(shippingAddress,address)%> |
| <%=langGenCity%> |
<%=city%> |
<%=emptyString(shippingCity,city)%> |
| <%=langGenLocation%> |
<%
if len(locState) > 0 then
Response.Write locState & ", "
end if
Response.Write locCountry
%>
|
<%
if len(shippingLocState) = 0 and len(shippingLocCountry) = 0 then
if len(locState) > 0 then
Response.Write locState & ", "
end if
Response.Write locCountry
else
if len(shippingLocState) > 0 then
Response.Write shippingLocState & ", "
end if
Response.Write shippingLocCountry
end if
%>
|
| <%=langGenZip%> |
<%=zip%> |
<%=emptyString(shippingZip,zip)%> |
| <%=langGenPhone%> |
<%=Phone%> |
<%=emptyString(shippingPhone,Phone)%> |
| <%=langGenCompany%> |
<%=CustomerCompany%> |
| <%=langGenShipping%> |
<%=shipmentMethod%> |
| <%=langGenPayment%> |
<%=paymentMsg(paymentType, total, cardNumber)%> |
| <%=langGenComments%> |
<%=emptyString(generalComments,langGenNotApplicable)%> |
| <%=langGenQty%> |
<%=langGenItemDesc%> |
<%=langGenSubTotal%> |
<%
'Get all rows for this cart
mySQL = "SELECT idCartRow,idProduct,quantity," _
& " unitPrice,description,sku,discAmt " _
& "FROM cartRows " _
& "WHERE cartRows.idOrder = " & validSQL(qIdOrder,"I") & " " _
& "ORDER BY idCartRow "
set rsTemp = openRSexecute(mySQL)
do while not rstemp.eof
'Assign record values to local values
IDCartRow = rstemp("idCartRow")
IDProduct = rstemp("idProduct")
Quantity = rstemp("quantity")
unitPrice = rstemp("unitPrice")
Description = rstemp("description")
SKU = rstemp("sku")
discAmt = rstemp("discAmt")
'Cater for orders entered before discounts were added
if isNull(discAmt) then
discAmt = 0.00
end if
%>
| <%=Quantity%> |
<%=SKU%>
<%=Description%> - <%=pCurrencySign & moneyS(unitPrice)%>
<%
'Display Download link if required, unless this is a
'printable view of the page in which case it's ignored.
if action <> "print" then
fileName = downloadFile(qIdOrder,IDCartRow)
if fileName <> "" then
Response.Write " (" & langGenDownload & ")"
end if
end if
Response.Write " "
'Write Discount (if any)
if discAmt > 0 then
Response.Write "* " & langGenDiscount & " - " & pCurrencySign & moneyS(discAmt) & " "
end if
'Get all options for this row
optionGroupsTotal = 0
mySQL = "SELECT optionPrice, optionDescrip " _
& "FROM cartRowsOptions " _
& "WHERE idCartRow = " & validSQL(idCartRow,"I")
set rsTemp2 = openRSexecute(mySQL)
do while not rstemp2.eof
'Assign record values to local values
optionDescrip = rstemp2("optionDescrip")
optionPrice = rstemp2("optionPrice")
'Write cartRowOptions line(s) (options)
Response.Write "* " & optionDescrip
if optionPrice <> 0 then
Response.Write " - " & pCurrencySign & moneyS(optionPrice)
end if
Response.Write " "
'Calculate options Sub Total
optionGroupsTotal = optionGroupsTotal + optionPrice
rstemp2.movenext
loop
call closeRS(rsTemp2)
%>
|
<%=pCurrencySign & moneyS(Cdbl(Quantity * (optionGroupsTotal + unitPrice - discAmt)))%>
|
<%
rstemp.movenext
loop
call closeRS(rsTemp)
%>
|
<%=langGenSubTotal%>:
|
<%=pCurrencySign & moneyS(subTotal)%>
|
<%
'If there's a discount, show discount and sub-total row
if discTotal > 0 then
%>
|
<%=discCode%> (<%=formatNumber(discPerc,2)%>%) -
<%=langGenDiscCode%>:
|
<%=pCurrencySign & moneyS(discTotal)%> (-)
|
|
<%=langGenSubTotal%>:
|
<%=pCurrencySign & moneyS(subTotal - discTotal)%>
|
<%
end if
%>
|
<%=langGenShipping%>:
|
<%=pCurrencySign & moneyS(shipmentTotal)%>
|
<%
'If there's a handling fee, show handling fee row
if handlingFeeTotal > 0 then
%>
|
<%=langGenHandlingFee%>:
|
<%=pCurrencySign & moneyS(handlingFeeTotal)%>
|
<%
end if
'If there are other fees, show other fee row
if otherFeeTotal > 0 then
%>
|
<%=langGenOtherFees%>:
|
<%=pCurrencySign & moneyS(otherFeeTotal)%>
|
<%
end if
if taxTotal > 0 Then
%>
|
<%=langGenTax%>:
|
<%=pCurrencySign & moneyS(taxTotal)%>
|
<% end if %>
|
*<%=langGenAdjustment%>:
|
<%
if isNumeric(adjustAmount) then
Response.Write pCurrencySign & moneyS(adjustAmount)
else
Response.Write pCurrencySign & moneyS("0.00")
end if
%>
|
|
<%=langGenTotal%>:
|
<%=pCurrencySign & moneyS(Total)%>
|
|
*<%=langGenAdjustment%> :
<%
if len(adjustReason) > 0 then
Response.Write adjustReason
else
Response.Write langGenNotApplicable
end if
%>
|
| |
|
<%
end sub
'**********************************************************************
'Draw horizontal line
'**********************************************************************
sub drawHLine()
%>


|

<%
end sub
'**********************************************************************
'Page Heading
'**********************************************************************
sub pageHeading()
%>

<%
end sub
'**********************************************************************
'Display default links
'**********************************************************************
sub defaultLinks()
%>
<%
call drawHLine()
end sub
'**********************************************************************
'Show payment pending message if order status is pending
'**********************************************************************
sub pendingMessage()
If orderStatus = "0" then
%>
|
<%
'Write "Payment Pending" message
Response.Write langGenOrdPendingMsg
call deposito()
'Give the customer the opportunity to re-submit
'payment for certain payment types.
if lCase(paymentType)="paypal" _
or lCase(paymentType)="cod" _
or lCase(paymentType)="2checkout" _
or lCase(paymentType)="authorizenet" _
or lCase(paymentType)="pag_digital" _
or lCase(paymentType)="custom" then
'Order Number is passed via the session object for the
'benefit of gateways that require the payment page to be
'a fixed URL.
session(storeID & "idOrderPaySubmit") = qIdOrder
%>
<%=langGenReSubPay%>
<%
end if
%>
|
<%
call drawHLine()
end if
end sub
'******************************************************************
'Check if an Order has any Downloadable Items
'******************************************************************
function orderHasDownloads(idOrder)
if isEmpty(idOrder) or not IsNumeric(idOrder) then
orderHasDownloads = false
exit function
end if
dim mySQL, rsTemp
mySQL="SELECT cartRows.idProduct " _
& "FROM cartRows, products " _
& "WHERE idOrder = " & validSQL(idOrder,"I") & " " _
& "AND products.idProduct = cartRows.idProduct " _
& "AND NOT (products.fileName IS NULL " _
& "OR products.fileName = '') "
set rsTemp = openRSexecute(mySQL)
if rsTemp.eof then
orderHasDownloads = false
else
orderHasDownloads = true
end if
call closeRS(rsTemp)
end function
%>