shop add to cart problem

Results 1 to 2 of 2

Thread: shop add to cart problem

  1. #1
    Join Date
    Dec 1969

    Default shop add to cart problem

    Hi,<BR><BR>i am using the code below to add a item from a previous page to the cart, the item is passed along via a querystring on the previous page, the first item gets added ok, however if i go back to selected a new item, it replaces the one previously in the cart! the code to add to cart is below, thanks!<BR><BR><BR>Function AddToCart()<BR> objDT = Session("Cart")<BR> Dim Product = Request.QueryString("code")<BR> objDR = objDT.NewRow<BR> objDR("Quantity") = Request.QueryString("qty")<BR> objDR("Product") = Product<BR> objDR("Cost") = Request.QueryString("cost")<BR> objDT.Rows.Add(objDR)<BR> Session("Cart") = objDT<BR> dg.DataSource = objDT<BR> dg.DataBind()<BR> lblTotal.Text = "£" & GetItemTotal()<BR>End Function

  2. #2
    Join Date
    Dec 1969

    Default RE: shop add to cart problem

    Your code is replacing the information each time, you are not storing the prior item that was added anywhere (i.e. you are not writing it back to your database). When you go to another page, it does not keep the information that is currently in your cart (Note: I am assuming your session("cart") refers to that persons cart number, such as an ID or GUID).<BR><BR>You may want to review the IBuySpy Shopping cart solution provided on They include the code and everything online (and you can download it), so that should help you to find a good solution.<BR><BR>JM

Posting Permissions

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