Get ready for BLACK FRIDAY shopping starting in

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>&lt;%
' 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 &lt;&gt; "" 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" ) &lt;&gt; "" 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

'-------------------------------------------------------
%&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;

&lt;body bgcolor="#FFFFFF" text="#000000"&gt;
&lt;p&gt;
&lt;%orderTotal = 0%&gt;
&lt;/p&gt;
&lt;form name="form1" method="post" action=""&gt;
&lt;div align="center"&gt;&lt;font size="4" face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;b&gt;&lt;font face="Comic Sans MS" size="3"&gt;
&lt;input type="hidden" name="updateQ" value="1"&gt;
&lt;/font&gt;&lt;/b&gt;YOUR SHOPPING CART &lt;/font&gt; &lt;/div&gt;
&lt;table width="75%" align="center"&gt;
&lt;tr&gt;
&lt;td&gt;PRODUCT&lt;/td&gt;
&lt;td&gt;PRICE&lt;/td&gt;
&lt;td&gt;QUANTITY&lt;/td&gt;
&lt;/tr&gt;
&lt;%
FOR i = 0 TO UBOUND( localCart, 2 )
IF localCart( CARTPID, i ) &lt;&gt; "" THEN
orderTotal = orderTotal + ( localCart( CARTPPRICE, i ) * localCart( CARTPQUANTITY, i ) )
%&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;&lt;font color="#000033" face="Arial, Helvetica, sans-serif" size="2"&gt;&lt;%=Server.HTMLEncode( localCart( CARTPNAME, i ) )%&gt;&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
&lt;td&gt;&lt;font face="Arial, Helvetica, sans-serif" size="2"&gt;&lt;b&gt;&lt;font color="#000033"&gt;&lt;%=formatCurrency( localCart( CARTPPRICE, i ) )%&gt;&lt;/font&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;input type="text" name="pq&lt;%=localCart(CARTPID, i )%&gt;" size="4" value="&lt;%=localCart(CARTPQUANTITY, i )%&gt;"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;%
END IF
NEXT
%&gt;
&lt;tr&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;ORDER TOTAL:&lt;font size="2"&gt;&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;&lt;font size="2"&gt;&lt;b&gt;&lt;font color="#000033" face="Arial, Helvetica, sans-serif"&gt;&lt;%=formatCurrency( orderTotal )%&gt;&lt;/font&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="default.asp"&gt;BACK TO SHOP&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;
&lt;input type="submit" name="Submit" value="Update Cart"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</font id=code></pre id=code>
thanks
[/code]

Reply to this topic