If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-03, 11:28
arif arif is offline
Registered User
 
Join Date: Oct 2002
Posts: 4
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.
Reply With Quote
  #2 (permalink)  
Old 04-20-03, 03:42
Memnoch1207 Memnoch1207 is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On