Vp Asp Shopping Cart _top_ -

order_id | user_id | order_date | total

Session("Cart") = cart Response.Redirect("view_cart.asp") %> <% cart = Session("Cart") total = 0 %> <table border="1"> <tr><th>Product</th><th>Price</th><th>Qty</th><th>Subtotal</th><th></th></tr> <% For i = 0 To UBound(cart) subtotal = cart(i, 2) * cart(i, 3) total = total + subtotal %> <tr> <td><%=cart(i,1)%></td> <td><%=FormatCurrency(cart(i,2))%></td> <td> <form method="post" action="update_cart.asp"> <input type="hidden" name="idx" value="<%=i%>"> <input type="number" name="qty" value="<%=cart(i,3)%>" min="0" style="width:60px"> <input type="submit" value="Update"> </form> </td> <td><%=FormatCurrency(subtotal)%></td> <td><a href="remove_item.asp?idx=<%=i%>">Remove</a></td> </tr> <% Next %> <tr><td colspan="3">Total</td><td><%=FormatCurrency(total)%></td><td></td></tr> </table> <a href="checkout.asp">Checkout</a> 5. Update cart ( update_cart.asp ) <% Dim idx, new_qty, cart idx = CInt(Request("idx")) new_qty = CInt(Request("qty")) cart = Session("Cart") If idx >= 0 And idx <= UBound(cart) Then If new_qty > 0 Then cart(idx, 3) = new_qty Else ' remove item For i = idx To UBound(cart) - 1 cart(i) = cart(i + 1) Next ReDim Preserve cart(UBound(cart) - 1) End If End If vp asp shopping cart

' Loop to find if product already in cart For i = 0 To UBound(cart) If cart(i, 0) = pid Then cart(i, 3) = cart(i, 3) + qty found = True Exit For End If Next order_id | user_id | order_date | total Session("Cart")

Here’s a to building a shopping cart with ASP Classic (VBScript) and a database (usually Access or SQL Server). 2) * cart(i

cart = Session("Cart") found = False