Asp Add To Cart
<% ' ***** Begin the functions to be called by the runtime script *****
' To find the actual runtime code scroll WAY DOWN....
' This function is written to enable the adding of multiples of an item
' but this sample always just adds one. If you wish to add different
' quantities simply replace the value of the Querystring parameter count.
' We didn't do this because we wanted to keep the whole thing simple and
' not get into using forms so it stayed relatively readable.
Sub AddItemToCart(iItemID, iItemCount)
If dictCart.Exists(iItemID) Then
dictCart(iItemID) = dictCart(iItemID) + iItemCount
Else
dictCart.Add iItemID, iItemCount
End If
Response.Write "
" & iItemCount & " of item # " & iItemID & " have been added to your cart.
" & vbCrLf
End Sub
Sub RemoveItemFromCart(iItemID, iItemCount)
If dictCart.Exists(iItemID) Then
If dictCart(iItemID) <= iItemCount Then
dictCart.Remove iItemID
Else
dictCart(iItemID) = dictCart(iItemID) - iItemCount
End If
Response.Write "
" & iItemCount & " of item # " & iItemID & " have been removed from your cart.
" & vbCrLf
Else
Response.Write "
Couldn't find any of that item your cart.
" & vbCrLf
End If
End Sub
Sub ShowItemsInCart()
Dim objKey
Dim aParameters ' as Variant (Array)
Dim sTotal, sShipping
%>
Item # |
Description |
Quantity |
Remove Item From Cart |
Price |
Totals |
<%
sTotal = 0
For Each objKey in dictCart
aParameters = GetItemParameters(objKey)
%>
<%=...
View Full Essay
|