Forums
This topic is locked
ultraeasy shopping car probelm
Posted 27 Feb 2002 06:18:22
1
has voted
27 Feb 2002 06:18:22 salud diaz posted:
can someone tell why I'm not able to add items to my shopping cart (ultraeasy shopping cart from www.webthang.co.uk/here's the shop_cart.asp code
<pre id=code><font face=courier size=2 id=code><%
' Define Constants
CONST CARTPID = 0
CONST CARTPNAME = 1
CONST CARTPPRICE = 2
CONST CARTPQUANTITY = 3
'------------------------------------------------
' GET THE SHOPPING CART
IF NOT isArray( Session( "cart" ) ) THEN
DIM localCart( 4, 20 )
ELSE
localCart = Session( "cart" )
END IF
'------------------------------------------------
' GET THE PRODUCT INFORMATION
productID = TRIM( Request( "pid" ) )
productName = TRIM( Request( "productName" ) )
productPrice = TRIM( Request( "productPrice" ) )
'---------------------------------------------------
' ADD ITEM TO SHOPPING CART
IF productID <> "" THEN
foundIT = FALSE
FOR i = 0 TO UBOUND( localCart )
IF localCart( CARTPID, i ) = productID THEN
localCart( CARTPQUANTITY, i ) = localCart( CARTPQUANTITY, i ) + 1
foundIT = TRUE
EXIT FOR
END IF
NEXT
IF NOT foundIT THEN
FOR i = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, i ) = "" THEN
localCart( CARTPID, i ) = productID
localCart( CARTPNAME, i ) = productName
localCart( CARTPPRICE, i ) = productPrice
localCart( CARTPQUANTITY, i ) = 1
EXIT FOR
END IF
NEXT
END IF
END IF
'------------------------------------------------
' UPDATE THE QUANTITIES IN THE SHOPPING CART
IF Request( "updateQ" ) <> "" THEN
FOR i = 0 TO UBOUND( localCart, 2 )
newQ = TRIM( Request( "pq" & localCart( CARTPID, i ) ) )
IF newQ = "" or newQ = "0" THEN
localCart( CARTPID, i ) = ""
ELSE
IF isNumeric( newQ ) THEN
localCart( CARTPQUANTITY, i ) = newQ
END IF
END IF
NEXT
END IF
'-------------------------------------------------------
' UPDATE SESSION VARIABLE WITH ARRAY
Session( "cart" ) = localCart
'-------------------------------------------------------
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>
<%orderTotal = 0%>
</p>
<form name="form1" method="post" action="">
<div align="center"><font size="4" face="Verdana, Arial, Helvetica, sans-serif"><b><font face="Comic Sans MS" size="3">
<input type="hidden" name="updateQ" value="1">
</font></b>YOUR SHOPPING CART </font> </div>
<table width="75%" align="center">
<tr>
<td>PRODUCT</td>
<td>PRICE</td>
<td>QUANTITY</td>
</tr>
<%
FOR i = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, i ) <> "" THEN
orderTotal = orderTotal + ( localCart( CARTPPRICE, i ) * localCart( CARTPQUANTITY, i ) )
%>
<tr>
<td><b><font color="#000033" face="Arial, Helvetica, sans-serif" size="2"><%=Server.HTMLEncode( localCart( CARTPNAME, i ) )%></font></b></td>
<td><font face="Arial, Helvetica, sans-serif" size="2"><b><font color="#000033"><%=formatCurrency( localCart( CARTPPRICE, i ) )%></font></b></font></td>
<td>
<input type="text" name="pq<%=localCart(CARTPID, i )%>" size="4" value="<%=localCart(CARTPQUANTITY, i )%>">
</td>
</tr>
<%
END IF
NEXT
%>
<tr>
<td> </td>
<td>ORDER TOTAL:<font size="2"><b></b></font></td>
<td><font size="2"><b><font color="#000033" face="Arial, Helvetica, sans-serif"><%=formatCurrency( orderTotal )%></font></b></font></td>
</tr>
<tr>
<td><a href="default.asp">BACK TO SHOP</a></td>
<td> </td>
<td>
<input type="submit" name="Submit" value="Update Cart">
</td>
</tr>
</table>
</form>
</body>
</html>
</font id=code></pre id=code>
thanks
[/code]