%
'************************************************************
' Version 6.50 July 7, 2005
' This routine displays the shopping cart and does recalculation
' if returnurl is passed, this routine returns back to that URL
' Have added recalculate functionality to Proceed - Dean 20/1/2006
'****************************************************************
Dim prodid, quantity, arrCart, scartItem
Dim strAction, pi, dualreprice
Dim returnurl
dim ContinueURL
dim Newcart
Dim Newcount
Dim tquantity
Dim confirm
dim testremove
Dim x
dim msg, stocklevel
ContinueURL=getconfig("xcontinueshopping")
If getconfig("xcontinueshoppingdynamic")="Yes" then
Setcontinueurl continueurl
If continueurl="" then
ContinueURL=getconfig("xcontinueshopping")
end if
end if
'******************************
' This form can call itself.
' We need to know if it is a new product add or just a recalculation
' Inputs are productid, quantity
'
'*******************************
sError=""
strAction=Request("Continue")
If straction="" then
strAction=Request("Continue.x")
end if
if straction<>"" then
strAction="CONTI"
else
strAction=Request("Checkout")
If straction="" then
straction=Request("Checkout.x")
end if
if straction<> "" then
strAction="PROCE"
else
strAction=request("Recalculate")
if straction="" then
straction=Request("REcalculate.x")
end if
if strAction<>"" then
strACTION="RECAL"
end if
end if
end if
if strAction<>"" then
ReprocessForm
else
ProcessNewadd
end if
' new item is to be added to cart
Sub ProcessNewAdd()
Dim rc
ShopInit
GetInputValues
arrCart = GetSessA("CartArray")
scartItem = GetSess("CartCount")
if scartitem="" then
responseredirect "shopemptycart.asp"
end if
If scartItem = 0 and prodid="" Then
shoperror getlang("langError01")
End If
If prodid <> "" Then
If scartItem = getconfig("xMaxCartitems") and scartItem>0 then
shoperror getlang("langerror02")
End If
prodi=""
CartInventoryproduct prodid, rc ' see if we are adding sub products
if rc=0 then
CartGetProduct prodid, rc
If rc=0 then
SetSess "newProductPrice",""
GetProductFeatures prodi ' in shopproductfeatures.asp
CartAddItem prodid, rc
else
shoperror getlang("langErrorNoProduct") & "id=" & prodid & "
"
end if
end if
end if
'VP-ASP 6.50 - precautionary security fix
returnurl=cleanchars(request("returnurl"))
if returnurl<>"" then
responseredirect returnurl
end if
DisplayForm
end sub
Sub GetInputValues
' Keys are
' productid = a number in the database
' quantity = a number of items
' db = database to change the database
'
Dim sOption, sUserText, sUserTextvalue
Dim optionnum
Dim maxFeatures
dim sMultiOption, sMultiValue
Dim i
prodid = Request("productid")
if prodid="" then
prodid=request("catalogid")
end if
If not isnumeric(prodid) then
shoperror "Product ID must be numeric"
End if
quantity = Request("quantity")
If Quantity<>"" then
ValidateQuantity quantity
end if
If prodid<>"" and quantity="" then
quantity=1
end if
' There can be up to 4 different features for a product option1, option2
maxfeatures=getconfig("xMaxFeatures")
SetSess "Maxfeatures",maxfeatures
end sub
'
Sub ReprocessForm
dim cartattributes, maxcartitems
arrCart = GetSessA("CartArray")
scartItem = GetSess("CartCount")
Select Case strAction
Case "CONTI"
responseredirect ContinueURL
Case "RECAL"
' Response.write "recalculating"
'moved functionality into it's own sub to accomodate for Proceed also - Dean 20/2/2006
recalculate
Case "PROCE"
'call recalculate sub to recalculate quantity on proceed - Dean 20/2/2006
recalculate
if getconfig("xsslshopcustomer") = "Yes" then
responseredirect getconfig("xssl") & "shopcustomer.asp"
else
responseredirect "shopcustomer.asp"
end if
End Select
DisplayForm
End Sub
' Sub display form
Sub DisplayForm()
ShopPageHeader
if getconfig("xbreadcrumbs") = "Yes" then
response.write "