<%@ LANGUAGE="VBSCRIPT" %> <% PageStrings = "18, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 68, 69, 70, 71, 121, 164, 222, 1078, 1086" '=============================================== ' 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. '=============================================== '----------------------------------------------- 'SPECIFY THAT THIS PAGE INCLUDES BASKET 'PROCESSING '----------------------------------------------- strThisPage = "basket" numDuplicate = 0 numDestinationTaxOnOff = 1 %> <% aryCart2 = aryCart '----------------------------------------------- 'SET PAGETITLE TAG '----------------------------------------------- strPageTitleHTML = GetString("PageTitle_ShoppingBasket") & " | " & GetString("Config_Webshopname") '----------------------------------------------- 'BASKET FUNCTIONS 'Might as well stick them on this page since 'they're only used here. '----------------------------------------------- '----------------------------------------------- 'INCREMENTS THE ARRAY IF THE ITEM ALREADY EXISTS 'Don't want a new line in the basket if one of 'the items already exists there. It's much 'nicer for the client if you just add one to the 'previous number. '----------------------------------------------- Function AddToExistingItem(numVersionID, numQuantity, aryCart2) For numCounter = 0 to Application(LICENSENUMBER & "basketmaxcapacity") If aryCart2(numCounter, 1) = numVersionID then If CLng(aryCart2(numCounter, 2) + numQuantity) > 32767 then aryCart2(numCounter, 2) = 32767 else aryCart2(numCounter, 2) = aryCart2(numCounter, 2) + numQuantity end if numDuplicate = 1 end if next AddToExistingItem = aryCart2 End Function '----------------------------------------------- 'ADD NEW ITEM LINE IF IT ISN'T PRESENT ALREADY 'If the item doesn't exist we need to add a new 'line in the basket. '----------------------------------------------- Function AddNewItemLine(numVersionID, numQuantity, aryCart2) aryCart2(numItemCount,1) = numVersionID If CDbl(numQuantity) > 32767 then aryCart2(numItemCount,2) = 32767 else aryCart2(numItemCount,2) = numQuantity end if numItemCount = numItemCount + 1 AddNewItemLine = aryCart2 End Function '----------------------------------------------- 'DELETE THE QUANTITY OF AN ITEM IF REMOVED 'If a remove link is clicked, we want to remove 'the quantity and then this line will be 'squeezed out later. '----------------------------------------------- Function TagRowForDeletion(numRemove, aryCart2) For numCounter = 0 to Application(LICENSENUMBER & "basketmaxcapacity") If aryCart2(numCounter, 1) = numRemove then aryCart2(numCounter, 1) = "" aryCart2(numCounter, 2) = "" numItemCount = numItemCount - 1 end if next TagRowForDeletion = aryCart2 End Function '----------------------------------------------- 'SQUASH ANY BLANKED LINES OUT OF THE ARRAY 'This cycles through the array and ensures that 'any lines where the quantity is blank (for a 'delete) or zero are squashed out of the array. '----------------------------------------------- Function SquashOutSpaces(aryCart2) For numCounter = 0 to (Application(LICENSENUMBER & "basketmaxcapacity") - 1) If aryCart2(numCounter, 2) = "" then aryCart2(numCounter, 1) = aryCart2(numCounter + 1, 1) aryCart2(numCounter, 2) = aryCart2(numCounter + 1, 2) aryCart2(numCounter + 1, 1) = "" aryCart2(numCounter + 1, 2) = "" end if next SquashOutSpaces = aryCart2 End Function '----------------------------------------------- 'FUNCTIONS SECTION ENDS ^ '----------------------------------------------- '----------------------------------------------- 'COLLECT PARAMETERS AND SET VALUES '----------------------------------------------- strReturnURL = replace(replace(Request.QueryString("strReturnURL"),":::","?"),"|||","&") strSpeedMessage = Request.Querystring("strSpeedMessage") numLineCount = Request.Querystring("numLineCount") numRemove = Request.QueryString("numRemove") V_ID = Request.QueryString("V_ID") P_ID = Request.QueryString("P_ID") Q = Request.Querystring("Q") If Request.Form("V_ID")<>"" then V_ID = Request.Form("V_ID") If Q="" then Q=1 If request.querystring("strFromForm") = "yes" then V_ID = "refresh" '----------------------------------------------- 'READ IN FORM VALUES IF RECALCULATE WAS CHOSEN 'CHANGE NULLS TO 0s AND SET numRemove TO DELETE '----------------------------------------------- for numCounter = 1 to numItemCount aryCart2(numCounter-1, 2) = (Request.querystring("T" & numCounter)) if Not IsNumeric(aryCart2(numCounter-1, 2)) then aryCart2(numCounter-1, 2) = "" numItemCount = numItemCount - 1 end if if aryCart2(numCounter-1, 2) = "0" then aryCart2(numCounter-1, 2) = "" numItemCount = numItemCount - 1 end if If IsNumeric(aryCart2(numCounter-1, 2)) then If aryCart2(numCounter-1,2) > 32767 then aryCart2(numCounter-1,2) = 32767 aryCart2(numCounter-1, 2) = Int(aryCart2(numCounter-1, 2)) If aryCart2(numCounter-1, 2) < 0 then aryCart2(numCounter-1, 2) = "" numItemCount = numItemCount - 1 end if end if next end if '----------------------------------------------- 'PROCESS THE CONTENTS OF THE BASKET ARRAY 'Decide what the basket script has been called 'to do and call the required functions. '----------------------------------------------- If V_ID <> "refresh" and V_ID <> "remove" then strReturnURL = strReturnURL & "&strShowBackLink=n" '----------------------------------------------- 'RUN MULTIPLE QTY ADD CODE OR SINGLE LINK ADD '----------------------------------------------- For numSpeedRows = 1 to numLineCount numTempV = Request.querystring("V" & numSpeedRows) numTempQ = Request.querystring("Q" & numSpeedRows)*1 If isnumeric(numTempQ) then If numTempQ > 32767 then numTempQ = 32767 end if If numTempV<>"" then aryCart2 = AddToExistingItem(numTempV, numTempQ, aryCart2) If numDuplicate = 0 then aryCart2 = AddNewItemLine(numTempV, numTempQ, aryCart2) end if end if numDuplicate = 0 Next end if If V_ID = "remove" then aryCart2 = TagRowForDeletion(numRemove, aryCart2) end if For numCounter = 1 to Application(LICENSENUMBER & "basketmaxcapacity") aryCart2 = SquashOutSpaces(aryCart2) next '----------------------------------------------- 'WRITE BASKET CONTENTS TO A COOKIE '----------------------------------------------- %> <% '----------------------------------------------- 'REDIRECT TO EMPTY CART PAGE '----------------------------------------------- If len(Request.Querystring("btnEmpty")) > 0 then response.redirect("emptybasket.asp") If len(Request.Querystring("btnCheckout")) > 0 then response.redirect("login.asp") If len(Request.Querystring("btnEnquire")) > 0 then response.redirect("login.asp?strCallMode=enquiry") '----------------------------------------------- 'PUT BUILDPAGE.ASP INCLUDE FURTHER DOWN! 'This can't go at the top like on the other 'pages otherwise the side menu basket will not 'be updated with the latest item added to the 'basket. '----------------------------------------------- %> <% '----------------------------------------------- 'IF NEED TO DISPLAY AN INSUFFICIENT STOCK 'MESSAGE THEN CANCEL META REFRESH '----------------------------------------------- If strQuantitiesAdjusted = "yes" then strReturnURL = "" '----------------------------------------------- 'BASKET NOT SHOWN - STRAIGHT BACK TO LAST PAGE '----------------------------------------------- If Application(LICENSENUMBER & "showbasket") = "n" AND strReturnURL <> "" then response.redirect(strReturnURL) '----------------------------------------------- 'READ PAGE TEMPLATE FROM FILE '----------------------------------------------- Call ReadFromTemplate(strTemplateLocation, aryPageTemplate, strBasketHTML, strCategoryListHTML) '----------------------------------------------- 'DETERMINE WHAT META REFRESH TO SET FOR BASKET 'If the 'showbasket' setting in the config is a 'number, we set meta refresh to that value in 'seconds providing there is a return URL. We 'then cancel this refresh if there is a speed- 'order error, and a message needs to be shown. '----------------------------------------------- If IsNumeric(Application(LICENSENUMBER & "showbasket")) AND strReturnURL <> "" then strMetaRefresh = "" If strSpeedMessage <> "" then strMetaRefresh = "" aryPageTemplate(0) = Replace(aryPageTemplate(0),"","") aryPageTemplate(0) = Replace(aryPageTemplate(0),"","" & vbcrlf & strMetaRefresh) '----------------------------------------------- 'WRITE FIRST HALF OF PAGE HTML '----------------------------------------------- response.write(aryPageTemplate(0)) %>
<% WriteString("PageTitle_ShoppingBasket") %>
<% If Not strMetaRefresh = "" Then '----------------------------------------------- 'BASKET SHOWN THEN REDIRECT AFTER A FEW SECONDS '----------------------------------------------- %>
<% WriteString("ContentText_ItemsAdded") %>

<% WriteString("ContentText_PleaseWait") %>
<% Else '----------------------------------------------- 'SPEEDORDER - QTY OR V_ID NOT VALID '----------------------------------------------- If V_ID = "speedorder" And strSpeedMessage <> "" Then %>
<% =strSpeedMessage %>
<% End If '----------------------------------------------- 'BASKET IS EMPTY '----------------------------------------------- If numItemCount = 0 then %>
<% WriteString("ContentText_BasketEmpty") %>


<% Else '----------------------------------------------- 'THERE ARE ITEMS IN THE BASKET '----------------------------------------------- %>
<% '----------------------------------------- 'PRICES INCLUDING TAX '----------------------------------------- If Application(LICENSENUMBER & "pricesinctax") = "y" Then If Application(LICENSENUMBER & "showtaxdisplay") = "y" Then %> <% Else %> <% End if Else '----------------------------------------- 'PRICES EXCLUDING TAX '----------------------------------------- If Application(LICENSENUMBER & "showtaxdisplay") = "y" Then %> <% Else %> <% End if End If %> <% If numItemCount > 0 Then For numCounter = 1 To numItemCount '----------------------------------------------- 'SUCK THE CONTENTS OF AN ARRAY RECORD FROM DB '----------------------------------------------- strQuery = "SELECT * FROM (((tblCactuShopTaxRates INNER JOIN tblCactuShopVersions ON tblCactuShopVersions.V_Tax = tblCactuShopTaxRates.T_ID) INNER JOIN tblCactuShopProducts ON tblCactuShopVersions.V_Product = tblCactuShopProducts.P_ID) INNER JOIN tblCactuShopProductProdTypeLink ON tblCactuShopProducts.P_ID = tblCactuShopProductProdTypeLink.PPT_ProductID) INNER JOIN tblCactuShopProdtype ON tblCactuShopProductProdTypeLink.PPT_ProdTypeID = tblCactuShopProdtype.PT_ID WHERE V_ID = " & aryCart2(numCounter - 1, 1) Call ExecuteSQL(strQuery, numCursorType, objRecordSet) numItemQuantity = aryCart2(numCounter - 1, 2) If InStr(strAdjustedQuantity,"z" & objRecordSet("V_ID") & "z") > 0 Then bgcolor="mainpageversionhighlight" Else bgcolor="mainpagetableline" End If %> <% '----------------------------------------- 'PRICES INCLUDING TAX '----------------------------------------- If Application(LICENSENUMBER & "pricesinctax") = "y" Then If Application(LICENSENUMBER & "showtaxdisplay") = "y" Then %> <% Else %> <% End if Else '----------------------------------------- 'PRICES EXCLUDING TAX '----------------------------------------- If Application(LICENSENUMBER & "showtaxdisplay") = "y" Then %> <% else %> <% end if End If %> <% objRecordSet.Close Next End If %>
<% WriteString("ContentText_ExTax") %>  <% WriteString("ContentText_IncTax") %> <% WriteString("ContentText_Price") %> <% WriteString("ContentText_Price") %>  <% WriteString("ContentText_Tax") %> <% WriteString("ContentText_Price") %> <% WriteString("ContentText_Qty") %>
<% response.write(objRecordSet("P_Name" & CStr(numLanguageID))) %>
&V_ID=<% =objRecordSet("V_ID") %>&strPageHistory=basket"><% response.write(objRecordSet("V_Name" & CStr(numLanguageID))) %> <% response.write(objRecordSet("V_CodeNumber")) %><% =aryCurrencies(1) & " " & CurrencyDisplay(numItemPriceExTax, 1, aryCurrencies(4)) %>  <% =aryCurrencies(1) & " " & CurrencyDisplay(numItemPriceIncTax, 1, aryCurrencies(4)) %> <% =aryCurrencies(1) & " " & CurrencyDisplay(numItemPriceIncTax, 1, aryCurrencies(4)) %> <% =aryCurrencies(1) & " " & CurrencyDisplay(numItemPriceExTax, 1, aryCurrencies(4)) %>  <% =numItemTaxRate * 100 %>% <% =aryCurrencies(1) & " " & CurrencyDisplay(numItemPriceExTax, 1, aryCurrencies(4)) %>  &V_ID=<% response.write("remove") %>" ><% WriteString("FormButton_Remove") %>
<% If strQuantitiesAdjusted="yes" Then %> <% End If numTotalBasketAmount = Round(numTotalPriceExTax + numTotalTaxAmount, 2) If Application(LICENSENUMBER & "showtaxdisplay") = "y" Then %> <% Else If Application(LICENSENUMBER & "pricesinctax") = "y" Then %> <% Else %> <% End If End If %>
<% WriteString("ContentText_OutOfStock") %>
 
<% WriteString("ContentText_OrderAmount") %> = <% =aryCurrencies(1) & " " & CurrencyDisplay(numTotalPriceExTax, 1, aryCurrencies(4)) %>
<% WriteString("ContentText_TaxWhereApp") %> = <% =aryCurrencies(1) & " " & CurrencyDisplay(numTotalTaxAmount, 1, aryCurrencies(4)) %>
<% WriteString("ContentText_Total") %> = <% =aryCurrencies(1) & " " & CurrencyDisplay(numTotalBasketAmount, 1, aryCurrencies(4)) %>
<% WriteString("ContentText_Total")%> = <% =aryCurrencies(1) & " " & CurrencyDisplay(numTotalPriceExTax + numTotalTaxAmount, 1, aryCurrencies(4)) %>
<% WriteString("ContentText_Total")%> = <% =aryCurrencies(1) & " " & CurrencyDisplay(numTotalPriceExTax, 1, aryCurrencies(4)) %>
" name="btnRecalculate">" tabindex="4" name="btnEmpty"><% If Application(LICENSENUMBER & "allowenquiries")="y" Then %>" name="btnEnquire"><% End If If (numTotalBasketAmount * 1) < Application(LICENSENUMBER & "minorderval") * aryCurrencies(3) Then %>" name="btnCheckout" onClick="alert('<% WriteString("Popup_OrderBelowMin")%> (<% =aryCurrencies(1) & " " & CurrencyDisplay(Application(LICENSENUMBER & "minorderval"), aryCurrencies(3), aryCurrencies(4)) %>)')"><% Else %>" name="btnCheckout"><% End If %>
<% End If %>
<% WriteSafeString(" title="<% WriteSafeString("ContentText_SaveRecoverBasketDesc") %>" border="0" width="25" height="22"><% WriteString("PageTitle_SaveRecoverBasketContents") %> <% WriteSafeString(" title="<% WriteSafeString("ContentText_SpeedOrderItemsDesc") %>" border="0" width="25" height="22"><% WriteString("PageTitle_SpeedOrder")%> <% WriteSafeString(" title="<% WriteSafeString("ContentText_MyAccountDesc") %>" border="0" width="25" height="22"><% WriteString("PageTitle_MyAccount")%>
<% WriteString("ContentText_SaveRecoverBasketDesc") %> <% WriteString("ContentText_SpeedOrderItemsDesc") %> <% WriteString("ContentText_MyAccountDesc") %>
<% If Not strReturnURL = "" Then %>


<% WriteString("ContentText_ContinueShopping") %> >>
<% End If End If '----------------------------------------------- 'WRITE LAST HALF OF PAGE HTML '----------------------------------------------- response.write(aryPageTemplate(1)) '----------------------------------------------- 'CLOSE DATA CONNECTIONS '----------------------------------------------- objDataConn.Close set objDataConn = nothing %>