%@ 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 %>
<%
End If
'-----------------------------------------------
'BASKET IS EMPTY
'-----------------------------------------------
If numItemCount = 0 then
%>
| <% WriteString("ContentText_BasketEmpty") %> |
<%
Else
'-----------------------------------------------
'THERE ARE ITEMS IN THE BASKET
'-----------------------------------------------
%>
<% End If %>
<% If Not strReturnURL = "" Then %>
<%
End If
End If
'-----------------------------------------------
'WRITE LAST HALF OF PAGE HTML
'-----------------------------------------------
response.write(aryPageTemplate(1))
'-----------------------------------------------
'CLOSE DATA CONNECTIONS
'-----------------------------------------------
objDataConn.Close
set objDataConn = nothing
%>