<%@ LANGUAGE = "VBScript" %> <% '----------------------------------------------------------- ' ASPilot.com - Cart ' ------------------------------ ' Copyright © 2004 Spliethof Inc ' ' This file lists all the products in the cart and manages the ' checkout process. PilotInitialize Response.Buffer = True GetCurrentCustomer MarkCurrentCustomerActive mode = EStr(Request.QueryString("mode")) ask2 = " onclick='return IntraAsk();'" specific = Decrypt(Request.QueryString("specific")) If Not PilotPageBegin("cart", Empty) Then Response.Redirect g.HomePageURL B2BCheckLogin "cart" Select Case mode Case "update" Step2orMultiShip = "step2" If Request.QueryString("multiship") = "yes" Then Step2orMultiShip = "multiship" If not isEmpty(Request.Form("update.x")) then 'if update totals is clicked UpdateCart Else UpdateCart 'takes directly to the step2 after updating the cart. Response.Write g.Str("cart_checklogin_text") DisplayLogin g.SecureURL & "cart.asp?mode=checklogin", g.SecureURL & "cart.asp?mode="&Step2orMultiShip End if Case "empty" EmptyCart End Select Select Case mode Case "massorder" If IsLoggedin or g("B2B_access")="full" Then For Each Key in Request.Form RequestedValue = Request.Form(Key) If RequestedValue&"X" <> "X" Then If IsNumeric(Left(Key, 1)) Then strOrderItems = strOrderItems & Left(key, InStr(1, key, "_")-1) & "," strModifiers = strModifiers & Right(key, Len(key)-InStr(1, key, "_")) & "|" strQuantity = strQuantity & RequestedValue & "," End If If Left(Key, 7) = "txtQnty" Then If InStr(1, RequestedValue, ",") > 1 Then 'Stupid form handling bastards. Accounting for more than one modifier per ID arrRequestedValue = Split(RequestedValue, ",") strMinQuantity = strMinQuantity & Right(Key, Len(key)-7) & "_" & Trim(arrRequestedValue(0)) & "," Else strMinQuantity = strMinQuantity & Right(Key, Len(key)-7) & "_" & RequestedValue & "," End If End If End If Next arrOrderItems = Split(strOrderItems, ",") arrQuantity = Split(strQuantity, ",") arrModifiers = Split(strModifiers, "|") 'Grab the min quantities arrMinQuantity = Split(Left(strMinQuantity, len(strMinQuantity)-1), ",") 'Load Up a dictionary k=0 Dim objDictionary Set objDictionary = CreateObject("Scripting.Dictionary") If NOT IsEmpty(arrMinQuantity) Then Do Until k > UBound(arrMinQuantity) arrMinQuan = Split(arrMinQuantity(k), "_") objDictionary.Add arrMinQuan(0), arrMinQuan(1) k=k+1 Loop End If 'Do for each item in the array. Could be a repeat, but a uniqe modifier count=0 Do Until count>=UBound(arrOrderItems) 'Do as many times as the quantity ordered with the particular item and mod If IsNumeric(arrQuantity(count)) Then intCount = Cint(arrQuantity(count)) If objDictionary.Exists(arrOrderItems(count)) Then If intCount < Cint(objDictionary.Item(arrOrderItems(count))) Then intCount = Cint(objDictionary.Item(arrOrderItems(count))) End If blnSuccessfulAdd = AddItemToCartFromGrid(arrOrderItems(count), arrModifiers(count), intCount) count=count+1 Else Response.Write "There was a problem in the cart. Please check your order and try again." count = UBound(arrOrderItems) End If Loop If blnSuccessfulAdd Then Response.Redirect g("HomePageURL")&"cart.asp" Else Response.Write "There was a problem with your cart. Please click the back button and try again" End If Else DisplayLogin g.SecureURL&"cart.asp?mode=checklogin", g.SecureURL&"pilot.asp?pg=products" End If Case "multiship" '99 signifys to DisplayCart that we have to deal with multi ship addresses If Request.QueryString("update") <> "" Then If Request.Form("checkout.x") <> "" Then Response.Redirect g.SecureURL & "cart.asp?mode=step2" End If If DisplayCart(99) = 0 Then Response.Redirect g.HomePageURL & "cart.asp" Else If DisplayCart(99) = 0 Then Response.Redirect g.HomePageURL & "cart.asp" End If Case "checklogin" 'Here we display the text that asks for a login if applicable: Response.Write g.Str("cart_checklogin_text") DisplayLogin g.SecureURL & "cart.asp?mode=checklogin", g.SecureURL & "cart.asp?mode=step2" Case "step2" 'Don't let the user skip our functions and trick the cart regarding quantities strRefererPage = LCase(Request.ServerVariables("http_referer")) If InStr(1, strRefererPage, "cart.asp") OR InStr(1, strRefererPage, "placeorder") OR InStr(1, strRefererPage, "cart.asp?mode=multiship") Then Response.Write g.Str("cart_step23_text") GetDefaultBillingInfo If DisplayCart(2) = 0 Then Response.Redirect g.HomePageURL & "cart.asp" Else Response.Write "Cannot Connect From Outside Source Page
" Response.Redirect g.HomePageURL & "cart.asp" End If Case "step3" strRefererPage = LCase(Request.ServerVariables("http_referer")) If InStr(1, strRefererPage, "cart.asp?mode=step2") OR InStr(1, strRefererPage, "cart.asp?mode=step3") Then Response.Write g.Str("cart_step23_text") If ValidBillingInfo() Then If DisplayCart(3) = 0 Then Response.Redirect g.HomePageURL & "cart.asp" Else If DisplayCart(2) = 0 Then Response.Redirect g.HomePageURL & "cart.asp" End If Else Response.Redirect g.HomePageURL & "cart.asp" End If 'Referer Check Case Else Dim rsCrt 'added one more If condition 03/10/03 since it repeats the cart in the login page also If isEmpty(Request.Form("checkout.x")) Then Set rsCrt = GetCartRs() If hasRecords(rsCrt) Then Response.Write g.Str("cart_step1_text") rsCrt.Close: Set rsCrt = Nothing If DisplayCart(1) = 0 Then 'here we show the page content (pc) from tblPages. "Your cart is currently empty, blah blah"..: Response.Write img1 & pc & "

We proudly accept: " Set rs = cnPILOT.Execute("SELECT ID, CARD, IMG FROM TBLCARDTYPES WHERE SHOWIT <> 0 ORDER BY ID ASC") Do Until rs.EOF Response.Write" " rs.MoveNext Loop 'here we display a small message such as "Secure transactions are encrypted for your protection. Click here to verify (show the verisign seal or something).." Response.Write g.Str("cart_step1_ssltext") End If End If End Select ' Case mode TemplateAfterPC PilotPageEnd PilotTerminate %>