%
'shopping cart code on this page -
'generates session variables with order items
Dim prodid, quantity, arrCart, scartItem
prodid = Request.Form("fproductid")
quantity = Request.Form("fquantity")
arrCart = Session("MyCart")
scartItem = Session("cartItem")
If scartItem = "" Then
Response.Redirect "error.asp?msg=" & Server.URLEncode ("We noticed you do not accept cookies. Please enable cookies to shop.")
else
if quantity <> "" AND quantity < 1 then
Response.Redirect "error.asp?msg=" & Server.URLEncode ("Please enter at least 1 as number of items you wish to order.")
end if
End If
If prodid <> "" Then
call addToCart()
Else
Dim strAction
strAction = UCase(Left(Request.Form("action"),5))
Select Case strAction
Case "CONTI" 'continue shopping
Response.Redirect "store.asp"
Case "RECAL" 'recalculate
call recalculateCart()
Case "PROCE" 'proceed to checkout
Response.Redirect "customer.asp"
End Select
'end if for updating or inserting new item in Cart
End If
sub addToCart()
If scartItem < maxCartItems Then
scartItem = scartItem + 1
End If
Session("cartItem") = scartItem
dim rsItem, sqlProductInfo
sqlProductInfo = "SELECT * FROM products WHERE (products.catalogID=" & prodid & ")"
'open connection - returns dbc as Active connection
call openConn()
Set rsItem = Server.CreateObject("ADODB.Recordset")
rsItem.Open sqlProductInfo, dbc, adOpenForwardOnly,adLockReadOnly,adCmdText
If Not rsItem.EOF Then
arrCart(cProductid,scartItem) = rsItem("catalogID")
arrCart(cProductCode,scartItem) = rsItem("ccode")
arrCart(cProductname,scartItem) = rsItem("cname")
arrCart(cQuantity,scartItem) = CInt(quantity)
arrCart(cUnitPrice,scartItem) = rsItem("cprice")
Session("MyCart") = arrCart
End If
rsItem.Close
set rsItem = nothing
call closeConn()
end sub
sub recalculateCart()
For i = 1 To scartItem
Dim tquantity
tquantity = Request.Form("quantity" & Cstr(i))
if isempty(tquantity) OR (tquantity = "") then
tquantity = 0
elseif (tquantity < 0) OR (isnumeric(tquantity)=false) then
tquantity = 0
end if
arrCart(cQuantity,i) = CInt(tquantity)
Next
'make temp array and set it empty
ReDim temparrcart(UBound(arrCart,1),UBound(arrCart,2))
Dim tempItems
tempItems = 0
For x = 1 to UBound(arrCart,1)
For y = 1 to UBound(arrCart,2)
temparrCart(x,y) = ""
Next
Next
For i = 1 to scartItem
confirm = Request.Form("selected" & CStr(i))
zeroQuantity = arrCart(cQuantity,i)
If confirm <> "" and zeroQuantity > 0 Then
tempItems = tempItems +1
For x = 1 to UBound(arrCart,1)
temparrCart(x,tempItems) = arrCart(x,i)
Next
End If
Next
For x = 1 to UBound(arrCart,1)
For y = 1 to UBound(arrCart,2)
arrCart(x,y) = temparrCart(x,y)
Next
Next
scartItem = tempItems
Session("cartItem") = scartItem
Session("MyCart") = arrCart
end sub
'procedure builds Cart contents table
sub showCart()
'double quote character
q = chr(34)
if scartItem = 0 then
strURL = Request.ServerVariables("HTTP_REFERER")
strFile = Request.ServerVariables("PATH_INFO")
if right(strURL,8) = right(strURL,8) then
strURL = "store.asp"
end if
strHTML = "
Shipping
information
Currently we are shipping to Lebanon only and all payments
are made on delivery.
Please add the following amounts to your order as shipping
fees
- Beirut (including Dbayeh) = 4$
- Nahr El Kalb- Mansourieh- Choueifat = 7$
- North, Chouf, South & Bekaa = 14$