Results 1 to 2 of 2

Thread: ASP Error

  1. #1
    Join Date
    Oct 2002
    Posts
    4

    Unanswered: ASP Error

    Hello,

    I am constructing a web site for a project, with a shopping cart. Now the shoping cart has 3 main functions: (1) add more products, (2) proceed to checkout and (3) update the quantities of a product. The first two work fine but i am having problems with the last function. Whenever you attempt to update the quantity of a product (whether adding or subtracting), it simply deletes all items in the shopping cart. I would be very grateful if anyone could help with any ideas, heres the code for updating the product quantities:

    ' Update Shopping Cart Quantities
    IF Request( "updateQ" ) <> "" THEN
    SET RS = Server.CreateObject( "ADODB.Recordset" )
    RS.ActiveConnection = Con
    RS.CursorType = adOpenDynamic
    RS.LockType = adLockOptimistic
    sqlString = "SELECT cart_id, cart_quantity FROM cart " &_
    "WHERE cart_userID=" & userID
    RS.Open sqlString
    WHILE NOT RS.EOF
    newQ = TRIM( Request( "pq" & RS( "cart_id" ) ) )
    deleteProduct = TRIM( Request( "pq" & RS( "cart_id" ) ) )
    IF newQ = "" OR newQ = "0" THEN
    RS.Delete
    ELSE
    IF isNumeric( newQ ) THEN
    RS( "cart_quantity" ) = newQ
    END IF
    END IF
    RS.MoveNext
    WEND
    RS.Close
    SET RS = Nothing
    END IF

    Thank you.

  2. #2
    Join Date
    Jan 2003
    Location
    Midwest
    Posts
    138
    I do mine a little differently I add the items to a dictionary object and update them this way.

    Code:
    if(Trim(Request("update")) <> "") then
    	for each x in Request.Form
    		if Left(x, 4) = "qty_" then
    			current = Split(x, "_")
    			if IsNumeric(Request(x)) then
    				if CInt(Request(x)) = 0 then
    					cartObj_count.Remove(CStr(current(1)))
    					cartObj_orderNum.Remove(CStr(current(1)))
    					cartObj_des.Remove(CStr(current(1)))
    					cartObj_price.Remove(CStr(current(1)))
    					cartObj_stock.Remove(CStr(current(1)))
    					cartObj_weight.Remove(CStr(current(1)))
    					cartObj_handling.Remove(CStr(current(1)))
    				else
    					cartObj_count(CStr(current(1))) = CInt(Request(x))
    				end if
    			end if
    		end if
    	next
    end if

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •