Almost all of the shopping carts available on the web run server side and therefore require server side scripting languages. In some cases the institution providing your secure credit card handling may provide you with access to a server side shopping cart that runs off of their servers. In other cases you have to implement the shopping cart on your own site. This is all very well when you have your own secure server and access to the appropriate server side scripting language but what can you do when you need a shopping cart but don't have access to either a secure server or server side scripting?
One alternative is to use a hosted e-commerce shopping cart software solution.
Note that this script has now been significantly rewritten to work less obtrusively with modern browsers. If you need a version that works with IE3/4 and Netscape 3/4 then please contact me about getting a copy of the prior version.
There are quite a few files that make up the shopping cart so I will go through them one by one to let you know what each is for and what you can do with it. Let's start with the html pages.
navigate.htm This is the navigation panel that appears at the left of all of the pages within the shopping cart. You will want to change the list of pages that this lists to include all of your product pages in place of my two examples but you need to keep the home link at the top and the order link at the bottom for the shopping cart to work and also the link to my site that uses build.gif.
welcome.htm This is the home page for the shopping cart. You can do whatever you like with this page.
The page is coded to use my form to mail php script the free version of which is included in this download. Alternatively you can modify the code to use any form to mail script.
thanks.htm This page is displayed after the order has been sent to thank your visitor for placing the order. The page can contain whatever you like as long as the onload parameter on the body tag is kept as this resets the order counts back to zero so that the same order doesn't get submitted multiple times.
cart.js This is the main shopping cart module which is attached to the frameset so as to be accessible from all pages. There are two field in this that you can change. The first is called max_items which you will need to change if you have more than 50 items for sale as this controls the size of the array where the order is stored. The second is called decimals and controls the number of decimal places for some of the money amounts.
validh.js This script validates the customer and shipping information to ensure that all mandatory fields are entered before the order is sent. The script also contains code to make sure that the order is only sent once. If you add extra fields to the order form then you may wish to add to the validation.
So that's the info on the individual files. I will finish off with a couple of remarks about a couple of peculiarities of this script as compared to a server side shopping cart.
Your visitor needs to add and remove items from their shopping cart using the Add One and Remove One buttons at the bottom of each product description. They will need to press the button once for each product they wish to order so if they want five of a particular product they will need to press the button five times. The remove button can only reduce the count back to zero, any additional removes will be ignored.
If your visitor selects to reload/refresh a page while within the shopping cart, all of the items that they have ordered so far will be cleared. Refreshing/reloading a page forces the initial setup code for the cart to be rerun and zeros out the order. The "cancel order" option at the bottom of the order page has exactly the same effect (as does the onload processing in the thanks page). You will probably want to let your visitors know that the refresh/reload option in their browser is equivalent to cancelling the order.
Finally, because the prices are coded into your HTML pages it is possible (although unlikely) for someone to create their own copy of the page containing different prices and use that to generate their order. You will need to verify that the correct prices have been quoted before processing the order.
This article written by Stephen Chapman, Felgall Pty Ltd.