ho questo script:
'===================================================
'a.shopKart 2.2
'(c) 1999-2000 Katrien Dermaut De Graeve - URLogy
'===================================================
'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.sessionid
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 "Default.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("custID")
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 = "Default.asp"
end if
strHTML = "<h3>Your shopping cart is empty.</h3>"
strHTML = strHTML & "<p><a href=" & q & strURL & q & ">Continue shopping.</a></p>"
else
strHTML = "<FORM action="& q &"addprod.asp"& q &" method="& q &"POST"& q &">"
strHTML = strHTML & "<table border=0 cellPadding=3 cellSpacing=2 width="&q&"100%"&q&">"
strHTML = strHTML & "<tr bgColor=darkblue>"
strHTML = strHTML & "<td><FONT color=white>Product code</FONT></td>"
strHTML = strHTML & "<td><FONT color=white>Product name</FONT></td>"
strHTML = strHTML & "<td><FONT color=white>Quantity</FONT></td>"
strHTML = strHTML & "<td><FONT color=white>Unit Price</FONT></td>"
strHTML = strHTML & "<td><FONT color=white>Total</FONT></td></tr>"
Dim isubtotal, i
isubtotal = 0
For i = 1 to scartItem
strHTML = strHTML & "<tr bgColor=navajowhite>"
strHTML = strHTML & "<td><input name=selected"& Cstr(i)&" type=checkbox value="&q&"yes"&q&" checked>" & arrCart(cProductCode,i) &"</td>"
strHTML = strHTML & "<td>" & arrCart(cProductname,i) & "</td>"
strHTML = strHTML & "<td><input type="&q&"text"&q&" name="&q & "quantity" & CStr(i) & q &" value="&q & arrCart(cQuantity,i) &q&" size=3></td>"
strHTML = strHTML & "<td>" & FormatCurrency(arrCart(cUnitPrice,i),2) & "</td>"
strHTML = strHTML & "<td>" & FormatCurrency(arrCart(cUnitPrice,i) * arrCart(cQuantity,i),2) & "</td>"
strHTML = strHTML & "</tr>"
isubtotal = isubtotal + (arrCart(cUnitPrice,i) * arrCart(cQuantity,i))
Next
strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td></td><td></td><td></td>"
strHTML = strHTML & "<td bgColor=darkblue><font color=white>Total</font></td>"
strHTML = strHTML & "<td bgColor=lightgoldenrodyellow>" & FormatCurrency(isubtotal,2) & "</td>"
strHTML = strHTML & "</tr>"
strHTML = strHTML & "</table>"
strHTML = strHTML & "<input name="&q&"action"&q&" type="&q&"submit"&q&" value="&q&"Continue shopping"& q &">"
strHTML = strHTML & "<input name="&q&"action"&q&" type="&q&"submit"&q&" value="&q&"Recalculate"&q&"><br>"
strHTML = strHTML & "<input name="&q&"action"&q&" type="&q&"submit"&q&" value="&q&"Proceed to check out"&q&">"
strHTML = strHTML & "</form>"
end if
response.write strHTML
end sub
%>
vorrei sapere come posso creare un carrello senza l'utilizzo dei cookies.ho trovato la sintassi session.sessionid ma essendo molto inusperto di asp non so come trattarla.
grazie
Cruz