%@ Language=VBScript %>
<%
'*************************************************************************
' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK!
' Function : Estimate Shipping Rates for an order
' 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
%>
<%
'Work fields
dim f, item
dim formArray
dim locShipZone
dim validFormFields
dim validRatesFound
dim shipError
'Customer
dim shippingZip
dim shippingCity
dim City
dim shippingLocState
dim shippingLocCountry
'Locations
dim locName
'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 if the session is still active
if isNull(idOrder) then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrCartEmpty)
end if
'Check if cart has any items
if cartQty(idOrder) = 0 then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrCartEmpty)
end if
'Get State and Country arrays
call getStateArray()
call getCountryArray()
if not isArray(countryArr) then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrCountry)
end if
'If the script called itself, do some checks and get rates
if Request.Form("formID") = "01" then
'Retrieve values from the form
shippingCity = validHTML(request.form("shippingCity"))
shippingLocState = validHTML(request.form("shippingLocState"))
shippingLocCountry = validHTML(request.form("shippingLocCountry"))
'Check Form Fields
if len(shippingCity) = 0 _
or len(shippingLocCountry) = 0 _
or not validLoc(shippingLocState,shippingLocCountry) then
'Form Fields are not valid
validFormFields = false
validRatesFound = false
else
'Form Fields are valid
validFormFields = true
'Determine Shipping Zone
locShipZone = getShipZone(shippingLocCountry,shippingLocState)
if locShipZone = null then
'Invalid shipping zone
validRatesFound = false
else
'Determine Totals to be used when calculating shipping rates
call calcShipTotals(idOrder)
'Free Shipping
if totalShipItems = 0 or totalShipWeight = 0 then
shipArray(0,0) = 0.00
shipArray(0,1) = langGenNoShipCharge
'Calculate shipping rates
else
'Initialize shipping error session variable
session(storeID & "shipError") = ""
'Calculate Store Rates
call calcStoreRates(totalShipPrice,totalShipWeight,locShipZone)
'Calculate Realtime Rates
call calcOnlineRates(totalShipWeight,shippingLocCountry,shippingLocState,shippingZip)
'Move error (if any) to local variable for later evaluation
if session(storeID & "shipError") <> "" then
shipError = session(storeID & "shipError")
end if
session(storeID & "shipError") = null
end if
'Execute Custom shipping rates user exit %>
<%
'Check shipping rate array
validRatesFound = validShipArray()
'For debug purposes, write shipping data as hidden HTML
Response.Write vbCrlf & "" & vbCrlf
'Store fields in a cookie
Response.Cookies("shipEst") = shippingZip & "*|*" & shippingLocState & "*|*" & shippingLocCountry & "*|*" & shippingCity
Response.Cookies("shipEst").expires = Date() + 30
end if
end if
else
'See if there's anything stored in the cookie and retrieve it
for each item in Request.Cookies
if item = "shipEst" then
formArray = Split(Request.Cookies(item),"*|*")
shippingCity = formArray(0)
shippingLocState = formArray(1)
shippingLocCountry = formArray(2)
exit for
end if
next
end if
%>
<%
'Close Database Connection
call closedb()
'**********************************************************************
'Main Shopping Cart Display Area.
'**********************************************************************
sub cartMain()
'If there were errors, show message (except first time page is shown)
if Request.Form("formID") = "01" and not (validFormFields and validRatesFound) then
%>
<%
if not validFormFields then
response.Write langErrInvForm
else
if shipError = "" then
response.write langErrNoShipRate
else
response.write shipError
end if
response.Write " (P" & totalShipPrice & " W" & totalShipWeight & " Z" & locShipZone & ")"
end if
%>
|
<%
end if
%>
<%
end sub
%>