<%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <% checkStoreOpen() if isCartBlank() then response.redirect "cartView.asp?rp=" & Request.QueryString("rp") ' *** Comment the following line to leave step 1 of checkout non-secure *** ' Requires "Enable SSL during customer checkout" to be enabled within Checkout Setup setupSecurePage "", false ' *** *** Dim submitted submitted = request.form("submitted") if submitted <> "" then submitted = true Dim enableCustomerLookup, enableVouchers, customerFound Dim enableNewsletter, newsletter Dim customerID, customerPassword, firstName, surname, company, street, suburb, stateID, state, stateName, other_state, postCode, countryID, countryName, phone, fax, email, website 'for go back button Dim d_firstName, d_surname, d_company, d_street, d_suburb, d_state, d_stateFromOther, d_postCode, d_stateID, d_countryID, d_countryName, d_phone Dim specialInstructions, updateCustomerDetails, paymentMethodID, voucherCode, dvoucherCode, eCartsessionID Dim pmode, stateNotRequired Dim lookupError, lookupUserFound Dim orderinStock Dim shippingMethodCount Dim chargeFees, feeTotal Dim taxID, taxrate, taxDescription, orderExTax, pricesIncTax Dim statesExist, countriesExist Dim countryJsCode Dim shippingJsCode Dim isCCOk, s_emailFromAddress, s_emailAddresses, pm_emailSent pm_emailSent = false Dim stateAutoLoad stateAutoLoad = 0 d_stateID = 0 stateName = 0 customerFound = false Dim noShippingMethods, interShipperFound noShippingMethods = false 'check for intershipper shipping method, collect delivery location type if present interShipperFound = isNumberValid(lookupItem("tblStore_Shipping","shippingID","shippingTypeID","8")) Dim valid, errorMSG valid = true Dim orderTotal, subTotal, shippingTotal, shippingRequired Dim countryMenuList Dim checkOutURL Dim enableSSL, sslDomain, minOrderLimit, maxOrderLimit Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open dbConnectionStr statesInDB() countriesInDB() stateNotRequired = returnStateNotRequired() SQLQuery = "SELECT enableCustomerLookup, enableVouchers, enableNewsletter, enableSSL, sslDomain, minOrderLimit, maxOrderLimit FROM tblStore_Checkout;" Set ds = objConn.Execute(SQLQuery) If not ds.eof and not ds.bof then enableSSL = ds("enableSSL") sslDomain = ds("sslDomain") minOrderLimit = ds("minOrderLimit") maxOrderLimit = ds("maxOrderLimit") enableCustomerLookup = ds("enableCustomerLookup") enableNewsletter = ds("enableNewsletter") enableVouchers = ds("enableVouchers") else enableSSL = false sslDomain = "" minOrderLimit = 0 maxOrderLimit = 0 enableCustomerLookup = true enableNewsletter = true enableVouchers = true end if ds.close set ds = nothing pmode = LCase(Trim(CStr(""&request.form("mode")))) if pmode = "goback" then loadPostedDetails() else if enableCustomerLookup AND (pmode = "lookup" OR isNumberValid(session("eCart_customerID"))) then lookupCustomer() end if if statesExist then countryJsCode = buildcountryJsCode() objConn.close set objConn = nothing loadCartTotals false if orderTotal > 0 AND orderTotal < minOrderLimit then errorMSG = "The minimum accepted order total is " & formatCurr(minOrderLimit, 2) & ", please adjust your order before continuing." valid = false elseIf maxOrderLimit > 0 AND orderTotal > maxOrderLimit then errorMSG = "The maximum accepted order total is " & formatCurr(maxOrderLimit, 2) & ", please adjust your order before continuing." valid = false end if Dim paymentMethod, pmRequired 'are there more than 1 payment methods that are active? Set ds = Server.CreateObject("ADODB.Recordset") SQLQuery = "SELECT paymentMethodID FROM tblPaymentMethods WHERE online = " & prepBoolean("true") & ";" ds.open SQLQuery,dbConnectionStr,3 if cLng(ds.recordCount) > 1 then 'more than 1, show payment method table pmRequired = true else 'only one, use it pmRequired = false if not ds.EOF and not ds.BOF then paymentMethod = ds("paymentMethodID") end if end if ds.close Set ds = Nothing Sub loadPostedDetails() if dMode <> true then on error resume next firstName = request.form("firstName") surname = request.form("surname") company = request.form("company") street = request.form("street") suburb = request.form("suburb") state = request.form("state") other_state = request.form("state") postCode = request.form("postCode") countryID = request.form("countryID") phone = request.form("phone") fax = request.form("fax") email = request.form("email") website = request.form("website") customerPassword = request.form("customerPassword") newsletter = request.form("newsletter") d_firstName = request.form("d_firstName") d_surname = request.form("d_surname") d_company = request.form("d_company") d_street = request.form("d_street") d_suburb = request.form("d_suburb") d_state = request.form("d_state") d_stateFromOther = request.form("d_state") d_postCode = request.form("d_postCode") d_countryID = request.form("d_countryID") d_phone = request.form("d_phone") specialInstructions = request.form("specialInstructions") updateCustomerDetails = request.form("updateCustomerDetails") customerID = request.form("customerID") paymentMethod = request.form("paymentMethod") paymentMethodID = request.form("paymentMethodID") voucherCode = request.form("voucherCode") dvoucherCode = request.form("dvoucherCode") shippingRequired = request.form("shippingRequired") eCartsessionID = request.form("eCartsessionID") End Sub Function buildcountryJsCode() if dMode <> true then on error resume next ' build JavaScript code for country/state dropdown's Dim f_jsCode Dim f_currentCID f_currentCID = 0 SQLQuery = "SELECT countryID, stateName, stateID FROM tblCountry_States ORDER BY countryID, stateName;" Set ds = objConn.Execute(SQLQuery) if not ds.EOF and not ds.BOF then i = 1 do until ds.EOF if Not ds("countryID") = f_currentCID then f_currentCID = ds("countryID") if f_jsCode <> "" then f_jsCode = f_jsCode & "} else if (countryID == " & f_currentCID & ") {" & vbCr else f_jsCode = f_jsCode & "if (countryID == " & f_currentCID & ") {" & vbCr end if i = 1 end if f_jsCode = f_jsCode & " addOption(menuObject, '" & replace(ds("stateName"), "'", "\'") & "','" & ds("stateID") & "');" & vbCr if stateID = ds("stateID") then stateAutoLoad = i end if i = i + 1 ds.MoveNext Loop f_jsCode = f_jsCode & "} else {" & vbCr f_jsCode = f_jsCode & "}" & vbCr end if ds.close Set ds = Nothing buildcountryJsCode = f_jsCode End Function Function buildRestrictionJsCode() if dMode <> true then on error resume next Dim jsCode, restrictionAllow Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open dbConnectionStr SQLQuery = "SELECT restrictionAllow FROM tblStore_Checkout;" Set ds = objConn.Execute(SQLQuery) If not ds.eof and not ds.bof then restrictionAllow = ds("restrictionAllow") else restrictionAllow = false end if ds.close set ds = nothing SQlQuery = "SELECT countryID, stateID FROM tblRestrictions ORDER BY countryID, stateID ASC;" Set ds = objConn.Execute(SQLQuery) if not ds.EOF and not ds.BOF then if restrictionAllow = true then jsCode = "var destOK = false;" & vbcr do until ds.EOF and not ds.BOF if restrictionAllow = false then jsCode = jsCode & " if (document.checkout.d_countryID[document.checkout.d_countryID.selectedIndex].value == " & ds("countryID") if ds("stateID") > 0 then jsCode = jsCode & " && document.checkout.d_stateID[document.checkout.d_stateID.selectedIndex].value == " & ds("stateID") end if jsCode = jsCode & ") {" jsCode = jsCode & " alert('Unfortunately we are unable to deliver to that " if ds("stateID") > 0 then jsCode = jsCode & "state" else jsCode = jsCode & "country" end if jsCode = jsCode & ".'); return false;" jsCode = jsCode & "}" & vbCr else jsCode = jsCode & " if (document.checkout.d_countryID[document.checkout.d_countryID.selectedIndex].value == " & ds("countryID") if ds("stateID") > 0 then jsCode = jsCode & " && document.checkout.d_stateID[document.checkout.d_stateID.selectedIndex].value == " & ds("stateID") end if jsCode = jsCode & ") { destOK = true; }" & vbcr end if ds.MoveNext Loop if restrictionAllow = true then jsCode = jsCode & " if (destOK == false) { alert('Unfortunately we are unable to deliver to that country.');return false; }" & vbcr end if ds.close objConn.close Set ds = Nothing Set objConn = Nothing buildRestrictionJsCode = jsCode end function Function returnDesc(thedescription) if dMode <> true then on error resume next if isNull(thedescription) then ReturnDesc = "" Exit Function end if If Cstr(thedescription) = "" then returnDesc = "" else returnDesc = " - " & replace(thedescription, "'", "\'") end if end function Function countryShippingCount(cID) if dMode <> true then on error resume next Dim csc_ds Set csc_ds = Server.CreateObject("ADODB.Recordset") SQLQuery = "SELECT Count(tblStore_Shipping.shippingID) AS CountOfshippingID FROM (tblStore_Shipping LEFT JOIN tblStore_ShippingCountries ON tblStore_Shipping.shippingID = tblStore_ShippingCountries.shippingID) LEFT JOIN tblCountry_States ON tblStore_ShippingCountries.stateID = tblCountry_States.stateID GROUP BY tblStore_ShippingCountries.countryID HAVING (((tblStore_ShippingCountries.countryID)=" & cID & "));" csc_ds.Open SQLQuery, dbConnectionStr, 3, 3 m = csc_ds("countOfshippingID") csc_ds.close set csc_ds = nothing countryShippingCount = m end function Sub statesInDB() if dMode <> true then on error resume next if databaseType = 1 then SQLQuery = "SELECT TOP 1 stateID FROM tblCountry_States;" elseIf databaseType = 2 then SQLQuery = "SELECT TOP 1 stateID FROM tblCountry_States;" elseIf databaseType = 3 then SQLQuery = "SELECT stateID FROM tblCountry_States LIMIT 1;" end if Set ds = objConn.Execute(SQLQuery) If not ds.eof and not ds.bof then statesExist = true else statesExist = false end if ds.close set ds = nothing end sub Sub countriesInDB() if dMode <> true then on error resume next if databaseType = 1 then SQLQuery = "SELECT TOP 1 countryID FROM tblCountries;" elseIf databaseType = 2 then SQLQuery = "SELECT TOP 1 countryID FROM tblCountries;" elseIf databaseType = 3 then SQLQuery = "SELECT countryID FROM tblCountries LIMIT 1;" end if Set ds = objConn.Execute(SQLQuery) If not ds.eof and not ds.bof then countriesExist = true else countriesExist = false end if ds.close set ds = nothing end sub Sub displayPaymentMethods() if dMode <> true then on error resume next SQLQuery = "SELECT tblPaymentMethods.paymentMethodID, tblPaymentMethods.paymentMethodName, tblPaymentMethods.shortDescription, tblPaymentMethods.isDefault, tblPaymentMethods.isCC, tblPaymentMethods.acceptedCards FROM tblPaymentMethods WHERE tblPaymentMethods.online = " & prepBoolean("true") & ";" Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open dbConnectionStr Set ds = objConn.Execute(SQLQuery) End Sub Sub loadStaffEmail() Dim ls_objConn,ls_ds,ls_SQLQuery ls_SQLQuery = "SELECT emailCustomerReceipt, receiptSubject, receiptFormat, receiptEmail, emailFromAddress, staffEmail1, staffEmail2, staffEmail3, ccStaff FROM tblStore_Email;" Set ls_objConn = Server.CreateObject("ADODB.Connection") ls_objConn.Open dbConnectionStr Set ls_ds = ls_objConn.Execute(ls_SQLQuery) If not ls_ds.eof and not ls_ds.bof then staffEmail1 = ls_ds("staffEmail1") staffEmail2 = ls_ds("staffEmail2") staffEmail3 = ls_ds("staffEmail3") s_emailFromAddress = ls_ds("emailFromAddress") end if ls_ds.close ls_objConn.close Set ls_ds = Nothing Set ls_objConn = Nothing s_emailAddresses = "" if isTextValid(staffEmail1) then s_emailAddresses = staffEmail1 & ";" if isTextValid(staffEmail2) then s_emailAddresses = s_emailAddresses & staffEmail2 & ";" if isTextValid(staffEmail3) then s_emailAddresses = s_emailAddresses & staffEmail3 & ";" if len(s_emailAddresses) > 0 then s_emailAddresses = left(s_emailAddresses, len(s_emailAddresses)-1) End Sub Function voucherInCart() 'checks if a voucher exists in the customers cart if dMode <> true then on error resume next Dim vic_objConn, vic_ds, vic_SQLQuery voucherInCart = false Set vic_objConn = Server.CreateObject("ADODB.Connection") vic_objConn.Open dbConnectionStr vic_SQLQuery = "SELECT ID FROM tblCartSessions_Products WHERE sessionID='" & session("eCartsessionID") & "' AND productID = -50;" Set vic_ds = vic_objConn.Execute(vic_SQLQuery) if not vic_ds.EOF and not vic_ds.BOF then voucherInCart = true vic_ds.Close vic_objConn.Close Set vic_ds = Nothing Set vic_objConn = Nothing End Function Function getAcceptedCardsImages(ci_paymentMethodAcceptedCards) if dMode <> true then on error resume next Dim gaci_s gaci_s = "" if isTextValid(ci_paymentMethodAcceptedCards) = false then exit function Dim ci_accCards ci_accCards = split(ci_paymentMethodAcceptedCards,"||") c_SQLQuery = "SELECT cardName, cardLogo, cardID FROM tblStore_AcceptedCards WHERE cardOnline=" & prepBoolean("true") & ";" Set c_ds = objConn.Execute(c_SQLQuery) If not c_ds.eof and not c_ds.bof then do until c_ds.eof for i = 0 to ubound(ci_accCards) if lcase(cstr(""&ci_accCards(i))) = lcase(cstr(""&c_ds("cardID"))) then if isTextValid(c_ds("cardLogo")) then gaci_s = gaci_s & "" else gaci_s = gaci_s & "" end if gaci_s = gaci_s & " " end if next c_ds.moveNext loop end if c_ds.close set c_ds = nothing getAcceptedCardsImages = left(gaci_s, len(gaci_s)-6) end Function %> <% =session("storePageTitle") %> onLoad="fillstates(document.checkout.stateID,document.checkout.countryID[document.checkout.countryID.selectedIndex].value, 0)<% if shippingRequired = true AND noShippingMethods = false AND valid = true then %>;fillstates(document.checkout.d_stateID, document.checkout.d_countryID[document.checkout.d_countryID.selectedIndex].value, 1)<% end if %><% if stateAutoLoad > 0 then send ";setTimeout('selstate()', 250)" %>"<% elseIf countriesExist=true AND shippingRequired=true AND noShippingMethods=false AND valid=true then %> onLoad="fillShipping(document.checkout.d_countryID[document.checkout.d_countryID.selectedIndex].value, 0);"<% end if %>>
Checkout - Step 1 of 4
<% if valid <> true then %>
<% =errorMSG %> <% else %>
Fields marked * are required. <% if enableCustomerLookup=true AND lookupUserFound <> true AND session("lookupCount") < 3 then %>
Existing Customer
If you are an existing customer please enter your email address and password below and click 'Lookup' to automatically load your details. Lost or forgotten passwords may be recovered here. <% if lookupError <> "" then %>
<% =lookupError %> <% end if %>
Email:
Password:
<% end if %>
<% if interShipperFound = true then %> <% end if %> <% if enableCustomerLookup then %> <% end if %> <% if enableNewsletter then %> <% end if %>
Contact Information
Name:
(First/Last)
* *
Company:
Street: *
Town/suburb: *
Country: <% if countriesExist then %> * <% else %> * <% end if %>
State: <% if statesExist = true then %> <% if stateNotRequired = False then %>*<% end if %>
Other state: <% end if %>
Postcode: *
Location type: *
Contact phone: *
Fax:
Email: *
Website:
Password: *
This password allows you to log in to the account section to track your order(s) status.
Newsletter: checked<% end if %>> Please send me further information in the future.
<% if shippingRequired = true AND noShippingMethods = false then %>
Shipping Details
Set my shipping details to the same as my contact details
Recipient's Name:
(First/Last)
*
Company:
Street: *
Town/suburb: *
Country: <% if countriesExist then %>*<% else %> * <% end if %>
State: <% if statesExist = true then %> <% if stateNotRequired = False then %>*<% end if %>
Other state: <% end if %>
Postcode: *
Contact phone: *
Special instructions:
<% end if %> <% if pmRequired = true then %>
<% if orderTotal > 0 then displayPaymentMethods() if not ds.EOF and not ds.BOF then isCCOk = isNumberValid(lookupItem("tblStore_AcceptedCards","cardID","cardOnline",prepBoolean("true"))) k = 0 do until ds.EOF if not isCCOk and ds("isCC") and not pm_emailSent = true then 'notify the merchant by email loadStaffEmail() sendEmail s_emailFromAddress, s_emailAddresses, "", "", "eCart - Payment Method Error", "=======================================================" & vbCr & "AUTOMATICALLY GENERATED EMAIL" & vbCr & "=======================================================" & vbCr & "Uniwin eCart Professional" & vbCr & vbCr & "At least one Credit Card type payment method exists, however there are no accepted cards set in the eCart Administration system." & vbCr & vbCr & "Please set at least one card to ""Online"" in the Checkout setup > Cards section of the eCart administration system for the payment method(s) to become available." & vbCr & "=======================================================", 2 pm_emailSent = true end if k = k + 1 if k > 2 then k = 1 %><% ds.MoveNext Loop end if ds.close objConn.close Set ds = Nothing Set objConn = Nothing end if %>
Payment method
"<% if pmode = "goback" and Trim(CStr(""&paymentMethodID)) = Trim(CStr(""&ds("paymentMethodID"))) then %> checked<% else if ds("isDefault")=true then send " checked" end if if ds("isCC") and not isCCOk then %> disabled<% end if %>><% =ds("paymentMethodName") %>
<%=ds("shortDescription")%><% if ds("isCC") then %>

<% if isCCOk then %><%=getAcceptedCardsImages(ds("acceptedCards"))%><% else %>Temporarily unavailable<% end if end if %>
<% else %> <% end if %> <% if enableVouchers = true AND voucherInCart() = false then 'disable vouchers if customer purchasing a voucher %>
Gift Voucher / Discount Voucher
If you have a gift or discount voucher please enter your Voucher Code in the space below.
Voucher Code:
<% end if %> <% SQLQuery = "SELECT feeName, amount FROM tblGenericFees;" Set ds = Server.CreateObject("ADODB.Recordset") ds.Open SQLQuery,dbConnectionStr,3 if not ds.EOF and not ds.BOF then %>
<% if ds.RecordCount > 1 then %>Note: All orders attract the following fees:
<% do until ds.EOF %>- <%=formatCurr(ds("amount"),2)%> - <%=ds("feeName")%>
<% ds.MoveNext loop else %>Note: All orders attract <%=formatCurr(ds("amount"),2)%> for <%=ds("feeName")%>
<% end if %>
<% end if ds.Close Set ds = Nothing %> <% if customerFound = true then %>
Customer details
Update my contact details if changes have been made.
<% end if %>
">
<% end if %>
<% ' ERROR REPORTING - DON'T REMOVE! if dMode <> true AND err.number <> 0 then reportError err.number, err.description, err.source, "" end if %>