<%@ LANGUAGE="VBSCRIPT" %> <% PageStrings = "14, 162, 163, 175, 180, 181, 182, 183, 184, 185, 186, 243, 244, 271, 272" %> <% '=============================================== ' CactuShop ASP Shopping Cart ' ©1999-2004 Cactusoft Ltd. www.cactusoft.com '=============================================== ' All rights reserved. ' Use of this code is covered by the terms and ' conditions in the license agreement. No ' unauthorized duplication or distribution is ' permitted. Cactusoft's copyright notices must ' remain in the ASP sections of the code. '=============================================== '----------------------------------------------- 'SAVE/RECOVER BASKET 'This feature lets potential customers compile 'an order and save it for recovery later. This 'is useful if a user has one or more regular 'orders they like to make, or if they need to 'return at a later date. Although the standard 'cookie basket will store items until the next 'visit, this only works if the user accesses 'from the same machine and hasn't cleared their 'caches. '----------------------------------------------- strCallMode = request.querystring("strCallMode") If strCallMode = "" then If len(request.querystring("btnSave"))>0 then strCallMode = "save" If len(request.querystring("btnRecover"))>0 then strCallMode = "recover" End if BSKT_Name = request.querystring("BSKT_Name") BSKT_Email = request.querystring("BSKT_Email") BSKT_ID = request.querystring("BSKT_ID") '----------------------------------------------- 'STORE EMAIL ADDRESS ON COOKIE '----------------------------------------------- response.cookies(Application(LICENSENUMBER & "cookiename"))("CD_EmailAddress") = BSKT_Email If BSKT_Name = "" then response.redirect("save_basket.asp?strProblem=noname&strCallMode="&strCallMode&"&BSKT_Email="&BSKT_Email&"&BSKT_Name="&BSKT_Name) If BSKT_Email = "" then response.redirect("save_basket.asp?strProblem=noemail&strCallMode="&strCallMode&"&BSKT_Email="&BSKT_Email&"&BSKT_Name="&BSKT_Name) If len(ErrorcheckEmail(strErrorText, numErrorNo, BSKT_Email)) > len(strErrorText) then response.redirect("save_basket.asp?strProblem=emailinvalid&strCallMode="&strCallMode&"&BSKT_Email="&BSKT_Email&"&BSKT_Name="&BSKT_Name) If strCallMode = "save" then '----------------------------------------------- 'CHECK IF BASKET EXISTS ALREADY '----------------------------------------------- strQuery = "SELECT BSKT_ID, BSKT_Name, BSKT_Email FROM tblCactuShopSaveBasket WHERE BSKT_Name='" & SqlSafe(BSKT_Name) & "' AND BSKT_Email='" & SqlSafe(BSKT_Email) & "'" Call ExecuteSQL(strQuery, numCursorType, objRecordSet) If objRecordSet.recordcount > 0 then If objRecordSet("BSKT_Name") <> BSKT_Name OR objRecordSet("BSKT_Email") <> BSKT_Email then response.redirect("save_basket.asp") End if If objRecordSet.recordcount = 1 then If objRecordSet("BSKT_Name")=BSKT_Name AND objRecordSet("BSKT_Email")=BSKT_Email then '----------------------------------------------- 'DELETE EXISTING BASKET '----------------------------------------------- strQuery = strDeleteStatementSyntax & " tblCactuShopSaveBasket WHERE BSKT_Name='" & SqlSafe(BSKT_Name) & "' AND BSKT_Email='" & SqlSafe(BSKT_Email) & "'" Call ExecuteSQL(strQuery, numCursorType, objRecordSet2) End if End if objRecordSet.close '----------------------------------------------- 'CREATE NEW BASKET RECORD '----------------------------------------------- strQuery = "INSERT INTO tblCactuShopSaveBasket (BSKT_Name, BSKT_Email, BSKT_Items, BSKT_Quantity, BSKT_Icount, BSKT_DateTime) VALUES (" &_ "'" & SqlSafe(BSKT_Name) & "'," &_ "'" & SqlSafe(BSKT_Email) & "'," &_ "'" & strItems & "'," &_ "'" & strQuantities & "'," &_ numItemCount & "," &_ strDateDelimiter & ReverseFormatYear(now()) & strDateDelimiter & ")" Call ExecuteSQL(strQuery, numCursorType, objRecordSet) Elseif strCallMode = "recover" then '----------------------------------------------- 'LOOK UP BASKET '----------------------------------------------- strQuery = "SELECT * FROM tblCactuShopSaveBasket WHERE BSKT_Name='" & SqlSafe(BSKT_Name) & "' AND BSKT_Email='" & SqlSafe(BSKT_Email) & "'" Call ExecuteSQL(strQuery, numCursorType, objRecordSet) If objRecordSet.recordcount = 1 then If objRecordSet("BSKT_Name") = BSKT_Name AND objRecordSet("BSKT_Email") = BSKT_Email then '----------------------------------------------- 'UPDATE CURRENT BASKET FROM SAVED VERSION '----------------------------------------------- numItemCount = objRecordSet("BSKT_Icount") strItems = objRecordSet("BSKT_Items") strQuantities = objRecordSet("BSKT_Quantity") aryTempItems2 = split(strItems, "z", -1) aryTempQuantity2 = split(strQuantities, "z", -1) numCounter = 0 Do while numCounter < 499 AND numCounter < Ubound(aryTempItems2) aryCart(numCounter,1) = CStr(aryTempItems2(numCounter)) aryCart(numCounter,2) = CStr(aryTempQuantity2(numCounter)) numCounter = numCounter + 1 Loop numCounter = 0 aryCart3 = aryCart aryCart2 = aryCart %> <% Else response.redirect("save_basket.asp?strProblem=notfound&strCallMode="&strCallMode&"&BSKT_Email="&BSKT_Email&"&BSKT_Name="&BSKT_Name) End if Else response.redirect("save_basket.asp?strProblem=notfound&strCallMode="&strCallMode&"&BSKT_Email="&BSKT_Email&"&BSKT_Name="&BSKT_Name) End if objRecordSet.close Else '----------------------------------------------- 'DELETE SAVED BASKET RECORD '----------------------------------------------- strQuery = strDeleteStatementSyntax & " tblCactuShopSaveBasket WHERE BSKT_Email='" & sqlsafe(BSKT_Email) & "' AND BSKT_Name='" & sqlsafe(BSKT_Name) & "' AND BSKT_ID=" & BSKT_ID Call ExecuteSQL(strQuery, numCursorType, objRecordSet) End if %> <% '----------------------------------------------- 'READ PAGE TEMPLATE FROM FILE '----------------------------------------------- Call ReadFromTemplate(strTemplateLocation, aryPageTemplate, strBasketHTML, strCategoryListHTML) '----------------------------------------------- 'WRITE FIRST HALF OF PAGE HTML '----------------------------------------------- response.write(aryPageTemplate(0)) %> <% If strCallMode = "save" then %> <% elseif strCallMode="recover" then %> <% else %> <% end if %>
<% WriteString("PageTitle_SaveCurrentBasketContents") %>
<% WriteString("ContentText_BasketSuccessfullySaved") %>
<% WriteString("ContentText_BasketNamePassword") %>* <% =BSKT_Name %>
<% WriteString("FormLabel_EmailAddress") %>* <% =BSKT_Email %>
<% WriteString("PageTitle_RecoverBasketContents") %>
<% WriteString("ContentText_BasketSuccessfullyRecovered") %> <% WriteString("ContentText_BasketSuccessfullyRecovered2") %>.
<% WriteSafeString(" title="<% WriteSafeString("ContentText_MinibasketViewBasketAltText") %>" vspace="1" border="0" width="25" height="22"><% WriteString("ContentText_MinibasketViewBasket") %>
<% WriteString("PageTitle_DeleteBasketContents") %>
<% WriteString("ContentText_SavedBasketDeleted") %>
<% WriteSafeString(" title="<% WriteSafeString("ContentText_ViewMyAccountHistory") %>" border="0" width="25" height="22"><% WriteString("ContentText_CustomerAccount") %>
<% '----------------------------------------------- 'WRITE LAST HALF OF PAGE HTML '----------------------------------------------- response.write(aryPageTemplate(1)) '----------------------------------------------- 'CLOSE DATABASE CONNECTION '----------------------------------------------- objDataConn.Close set objDataConn = nothing %>