<% option Explicit Response.Buffer = true %> <% Dim gstrGUID gstrGUID = initUser() dim strConnectionString strConnectionString = Application("ADS_connectionString") Call Main() Sub Main() dim intQty, strPartNo, strReferer, strBuy, strSelect dim strName, intPos, item intQty = Request("qty") strPartNo = Request("ID") strReferer = "shopcart.asp" ' this code pulls the color from the form collection based on value of the buy1.x field For each item in Request.Form strName = mid(item,1,3) if strName = "buy" then intPos = instr(1,item,".") strSelect = "id" & mid(item,4,intPos-4) strPartNo = request.form(strSelect) End If next If Len(trim(strPartNo)) = 0 OR strPartNo = "Select Color" then Response.Clear Response.Redirect( strReferer ) ' server.transfer ( strReferer ) End If If strPartNo <> "" and intQty <> "" then call add_or_Update (strPartNo, intQty) ' server.transfer ( strReferer ) Response.clear() Response.redirect( strReferer) End Sub '-------------------------- functions ------------------------ sub add_or_Update ( strPartNo, intQty) Dim oCmd, rs Dim intNewQty Dim strCart Set oCmd = Server.CreateObject("ADODB.Command") oCmd.ActiveConnection = strConnectionString oCmd.CommandText = "prod_exists" oCmd.CommandType = 4 Set rs = oCmd.Execute (, Array(gstrGUID, strPartNo)) if NOT rs.EOF then ' Here to update an existing shopping cart Item intNewQty = rs(0) + intQty rs.close set rs = Nothing Set oCmd = Server.CreateObject("ADODB.Command") oCmd.ActiveConnection = strConnectionString oCmd.CommandType = 4 oCmd.CommandText = "update_item" oCmd.Execute , Array(intNewQty, gstrGUID, strPartNo), &H00000080 else ' here to add an item rs.close set rs = Nothing Set oCmd = Server.CreateObject("ADODB.Command") oCmd.ActiveConnection = strConnectionString oCmd.CommandType = 4 oCmd.CommandText = "add_item" oCmd.Execute , Array(gstrGUID, strPartNo, intQty), &H00000080 end If set oCmd = Nothing strCart = Request.Cookies ("adsCart") if strCart = "" then strCart = 0 Response.Clear Response.Cookies ("adsCart")= Cint(strcart) + Cint(intQty) Response.Cookies ("adsCart").expires = now() + 90 end Sub %>