<% id = trim(request("id") & "") const ItemId = 0 const ItemPrice = 1 const ItemQuantity = 2 const ItemTitle = 3 if (id <> "" and isNumeric(id)) then 'look up item info dim price price = 0 set cn = server.CreateObject("adodb.connection") cn.connectionstring = constr cn.open set rs = cn.execute("Select ItemPrice, ItemTitle from Items where ItemId=" & id) if not rs.eof then price = rs("ItemPrice") title = rs("ItemTitle") end if cn.close: set cn = nothing if not isArray(Session("Cart")) then dim cart(4,100) else cart = Session("Cart") end if dim bFound bFound = false for i = 0 to ubound(cart,2) if cart(ItemId,i) = id then 'item found in cart, update it if (request.Form("quantity") = "0") then 'delete is empty, so update quantity cart(ItemId,i) = "" cart(ItemPrice,i) = "" cart(ItemQuantity,i) = "" cart(ItemTitle,i) = "" elseif (IsNumeric(request.Form("quantity"))) then cart(ItemQuantity,i) = request.Form("quantity") end if bFound = true exit for end if next if not bFound then 'add item to cart for i = 0 to ubound(cart,2) if (cart(ItemId,i) = "") then cart(ItemId,i) = id cart(ItemPrice,i) = price if request.Form("quantity") <> "" and isnumeric(request.Form("quantity")) then cart(ItemQuantity,i) = request.Form("quantity") else cart(ItemQuantity,i) = 1 end if cart(ItemTitle,i) = title exit for end if next end if dim tmpCart(4,100) j = 0 for i = 0 to ubound(cart,2) if (cart(ItemId,i) <> "") then tmpCart(ItemId,j) = cart(ItemId,i) tmpCart(ItemPrice,j) = cart(ItemPrice,i) tmpCart(ItemQuantity,j) = cart(ItemQuantity,i) tmpCart(ItemTitle,j) = cart(ItemTitle,i) j = j + 1 end if next Session("Cart") = tmpCart end if %> Uncle Jed Shopping Cart
Buddy Ebsen's Uncle Jed Country

 

Home

Fine Art

Gallery

About Buddy Ebsen

Visit our online store

Authorized Dealers

Contact Us

Limited Editions by Buddy Ebsen

Click the title of any picture to view the larger image

<% bHasItems = false if (IsArray(tmpCart)) then for i = 0 to ubound(tmpCart,2) if (tmpCart(ItemId,i) <> "") then bHasItems = true exit for end if next end if if bHasItems then %> <% color = false for i = 0 to ubound(tmpCart,2) if (tmpCart(ItemId,i) <> "") then sCart = sCart & "ItemId: " & tmpCart(ItemId,i) & vbcrlf & _ "Item Price: " & tmpCart(ItemPrice,i) & vbcrlf & _ "Item Quantity: " & tmpCart(ItemQuantity,i) & vbcrlf & _ "Item Title: " & tmpCart(ItemTitle,i) & vbcrlf & vbcrlf if color then style="class=""alt""" color = false else color = true style = "style='background-color:white;'" end if thisItemTotal = cdbl(tmpCart(ItemQuantity,i)) * cdbl(tmpCart(ItemPrice,i)) total = total + thisItemTotal %> <% end if next%>
Title Quantity Price Delete / Update
><%=tmpCart(ItemTitle,i)%> > ><%Response.Write(formatcurrency( thisItemTotal ))%> >
  Total: <%=formatcurrency(total)%> ">
<%else%>
Your cart is empty.
<%end if%>

Images and materials used on this site Copyrightę Buddy and Dorothy Ebsen or used by permission.
All rights reserved. Site Maintenance by Advanced Webpage Design