%
'Constants
const MAX_ITEMS=18
' We implemented this this way so if you attach it to a database you'd only need one call per item
Function GetItemParameters(iItemID)
Dim aParameters ' Will contain 4 string values : image path, product,description, price
' However we need to keep price so it can be converted to a
' single for computation hence no currency symbol. This array
' can also be expanded to contain any other information about the
' product that you might want to pull from the DB.
Select Case iItemID
'Case 0
' aParameters = Array("./images/Products/unavailable.gif","Unavailable","Product Currently Unavailable/Updates","0.0")
Case 1
aParameters = Array("./images/Products/AstroPic.gif","AstroPic","Astrophotography management system","39.95")
Case 2
aParameters = Array("./images/Products/BizWhiz.gif","BizWhiz","Purchase Order and Invoice Small Business System","189.95")
Case 3
aParameters = Array("./images/Products/OddsNEnds.gif","Odds&Ends Book","Thought excursions from the world of puma (50 pages)","19.95")
Case 4
aParameters = Array("./images/Products/ClinTrak.gif","ClinTrak","Clinical database","349.95")
Case 5
aParameters = Array("./images/Products/DotsTrak.gif","DotsTrak","Delivery Order Transaction System","89.95")
Case 6
aParameters = Array("./images/Products/EcTrak.gif", "EcTrak","E-Commerce automatic web generation System ","19.95")
Case 7
aParameters = Array("./images/Products/Fortune.gif", "Fortune","Daily Quote/Fortune!","19.95")
Case 8
aParameters = Array("./images/Products/LanTrak.gif", "LanTrak","Centralized LAN inventory","49.95")
Case 9
aParameters = Array("./images/Products/PartTrak.gif", "PartTrak","Parts","39.95")
Case 10
aParameters = Array("./images/Products/PicTrak.gif", "PicTrak","Photography management system","39.95")
Case 11
aParameters = Array("./images/Products/SwimTrak.gif", "SwimTrak","Swim competition progress tracking","119.95")
Case 12
aParameters = Array("./images/Products/TKDTrak.gif", "TKDTrak","Martial Arts Software","89.95")
Case 13
aParameters = Array("./images/Products/TechTrak.gif", "TechTrak","Help Desk problem/solution tracking","89.95")
Case 14
aParameters = Array("./images/Products/TidyTrak.gif", "TidyTrak","Services Provider Business Package","189.95")
Case 15
aParameters = Array("./images/Products/TravTrak.gif", "TravTrak","Travel Reservations tutorial and assistant","39.95")
Case 16
aParameters = Array("./images/Products/WoTrak.gif", "WoTrak","Work Order/Help Desk tickets", "89.95")
Case 17
aParameters = Array("./images/Products/WWWTrak.gif", "WWWTrak","Internet Provider Billing Software", "99.95")
End Select
' Return array containing product info.
GetItemParameters = aParameters
End Function
%>
<% ' ***** Begin the functions to be called by the runtime script *****
'shop_checkout.gif -> checkout.gif
'shop_look.gif -> continue.gif
'aParameters(2) -> aParameters(3)
Sub ShowHeader()
%>

<%
End Sub
' 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
ShowHeader()
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
ShowHeader()
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 ShowUnavailable()
%>
'

Sorry!!! Product currently unavailable
This product is currently unavailable due to some condition or upgrades.
Please check back at a later time.
Please yahoo, email or call if you need more information
Yahoo:
Email:omnisoft@omnisoft.net
Phone:303 457-1616
Sorry for any inconvenience


Home
<%
end sub
Sub ShowItemsInCart()
Dim Key
Dim aParameters ' as Variant (Array)
Dim sTotal
'ShowHeader
%>
| Item # |
Product |
Quantity |
Remove Item From Cart |
Price |
Totals |
<%
sTotal = 0
For Each Key in dictCart
aParameters = GetItemParameters(Key)
%>
| <%= Key %> |
<%= aParameters(1) %> |
<%= dictCart(Key) %> |
Remove One Remove All |
$<%= aParameters(3) %> |
$<%= FormatNumber(dictCart(Key) * CSng(aParameters(3)),2) %> |
<%
sTotal = sTotal + (dictCart(Key) * CSng(aParameters(3)))
Next
%>
| Total: | $<%= FormatNumber(sTotal,2) %> |
<%
End Sub
Sub ShowFullCatalog()
Dim aParameters ' as Variant (Array)
Dim I
Dim iItemCount ' Number of items we sell
' If you are really going to use this sample this should probably be pulled from a DB
iItemCount = MAX_ITEMS
ShowHeader
%>
| Image |
Product |
Description Click product description for more info |
Price |
Buy |
<%
For I = 1 to iItemCount
aParameters = GetItemParameters(I)
%>
 %>) |
<%= aParameters(1) %> |
<%= aParameters(2) %> |
$<%= aParameters(3) %> |
|
<%
Next 'I
%>
<%
End Sub
Sub PlaceOrder()
Dim Key
Dim aParameters ' as Variant (Array)
Dim sTotal
%>
| Item # |
Product |
Description |
Quantity |
Price |
Totals |
<%
sTotal = 0
For Each Key in dictCart
aParameters = GetItemParameters(Key)
%>
| <%= Key %> |
<%= aParameters(1) %> |
<%= dictCart(Key) %> |
$<%= aParameters(3) %> |
$<%= FormatNumber(dictCart(Key) * CSng(aParameters(3)),2) %> |
<%
sTotal = sTotal + (dictCart(Key) * CSng(aParameters()))
Next
%>
| Total: | $<%= FormatNumber(sTotal,2) %> |
<%
End Sub
%>
<% ' ***** Begin the infamous runtime script *****
' Declare our Vars
Dim dictCart ' as dictionary
Dim sAction ' as string
Dim iItemID ' as integer
Dim iItemCount ' as integer
' Get a reference to the cart if it exists otherwise create it
If IsObject(Session("cart")) Then
Set dictCart = Session("cart")
Else
' We use a dictionary so we can name our keys to correspond to our
' item numbers and then use their value to hold the quantity. An
' array would also work, but would be a little more complex and
' probably not as easy for readers to follow.
Set dictCart = Server.CreateObject("Scripting.Dictionary")
End If
' Get all the parameters passed to the script
sAction = CStr(Request.QueryString("action"))
iItemID = CInt(Request.QueryString("item"))
iItemCount = CInt(Request.QueryString("count"))
'We have to check here because for checkout we will load
'another form
if sAction<>"checkout" then
%>
|
<%
end if
%>
<%
' Select action based on user input
Select Case sAction
Case "add"
if iItemID<>0 then
AddItemToCart iItemID, iItemCount
ShowItemsInCart
%>
|

<%
else
ShowUnavailable()
end if
Case "del"
RemoveItemFromCart iItemID, iItemCount
ShowItemsInCart
%>
|

<%
Case "viewcart"
ShowHeader()
ShowItemsInCart
%>
|

<%
Case "checkout"
'PlaceOrder
Response.redirect "./ccorder.htm"
%>
<%
Case Else ' Shop
ShowFullCatalog
%>
|
<%
End Select
' Return cart to Session for storage
Set Session("cart") = dictCart
%>
|