%
'************************************************************
' Version 4.00 Nov 17,2001
' This routine displays the shopping cart and does recalculation
' if returnurl is passed, this routine returns back to that URL
'*******************************************************
Dim prodid, quantity, arrCart, scartItem
Dim strAction, pi, dualreprice
Dim returnurl
dim ContinueURL
ContinueURL=getconfig("xcontinueshopping")
'******************************
' 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
Response.Redirect "shopemptycart.asp"
end if
If scartItem = 0 and prodid="" Then
Response.Redirect "shoperror.asp?msg=" & Server.URLEncode (LangError01)
End If
If prodid <> "" Then
If scartItem = getconfig("xMaxCartitems") and scartItem>0 then
Response.Redirect "shoperror.asp?msg=" & Server.URLEncode (Langerror02)
End If
CartAddItem prodid, rc
if rc > 0 then
sError=LangErrorNoProduct & "id=" & prodid
end if
returnurl=request("returnurl")
if returnurl<>"" then
response.redirect returnurl
end if
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
'------------------------------------
' VP-ASP Security Patch - 02/2006
'------------------------------------
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
prodi=""
prodi=""
If prodid<>"" then
CartGetProduct prodid, rc
SetSess "newProductPrice",""
GetProductFeatures prodi ' in shopproductfeatures.asp
end if
end sub
'
Sub ReprocessForm
dim cartattributes, maxcartitems
arrCart = GetSessA("CartArray")
scartItem = GetSess("CartCount")
Select Case strAction
Case "CONTI"
Response.Redirect ContinueURL
Case "RECAL"
' Response.write "recalculating"
dim Newcart
Dim Newcount
Dim tquantity
Dim confirm
dim testremove
Dim x
dim msg, stocklevel
cartattributes=cMaxCartAttributes
maxcartitems=getconfig("xmaxcartitems")
newcount=0
ReDim newcart(cartAttributes,maxCartItems)
For i = 1 to scartItem
confirm = Request.Form("selected" & CStr(i))
tquantity = Request.Form("Quantity" & Cstr(i))
if Not isnumeric(tquantity) then
tquantity=1
end if
validatequantity tquantity
stocklevel=arrCart(cStocklevel,i)
If getconfig("XcheckStocklevel")="Yes" Then
If stocklevel<>"" then
CheckStockLevelRecalculate stocklevel,tquantity, arrcart, scartitem, i, msg
end if
end if
arrCart(cQuantity,i)=tquantity
if getconfig("xcartremoveChecked")="Yes" Then
testremove="yes"
else
testremove=""
end if
If confirm <> testremove or tquantity=0 Then
else
newcount=newcount+1
cartattributes=cMaxCartAttributes
for x = 1 to cartAttributes
NewCart(x, newcount) = arrCart(x,i)
next
ProductPrice=Newcart(cOriginalPrice,newcount)
NewCart(cUnitPrice,newcount)=ProductPrice
DiscountPrice=ProductPrice
CalculateUserPrice ProductPrice, tquantity, DiscountPrice, Newcart, Newcount
Newcart(cUnitPrice,newcount)=DiscountPrice
Convertcurrency discountPrice, dualreprice
Newcart(cDualPrice,newcount) = dualreprice
end if
Next
SetSess "CartCount", newcount
SetSessA "CartArray", Newcart
arrcart=Newcart
scartitem=newcount
Serror=msg
Case "PROCE"
Response.Redirect "shopcustomer.asp"
End Select
DisplayForm
End Sub
' Sub display form
Sub DisplayForm()
ShopPageHeader
If Serror<>"" then
response.write xfont & serror & "
"
end if
arrCart = GetSessA("CartArray")
scartItem = GetSess("CartCount")
FormatFormFields
ShopPageTrailer
end sub
' Format form
Sub FormatFormFields
%>