View Full Version : Is it possible to build a JS Shopping Cart w/out a database?

09-26-2005, 05:22 PM
Seems like a strange questions, but I am trying to figure out how to build a shopping cart with JS and no database. The function is not to actually order products, but to select which products you want and to end up at an invoice type page. I don't need the information stored, once the invoice is created, the info does not need to be kept. Here is an example

page 1 - select products

page 2 - calculate bundled price & 'if sold seperately' price
add in other taxes and surcharges to products chosen
Add in Installation fees (if applicable)
mulitply the total bundled price by 2 to get deposit required (if applicable)
Give product description to the products choosen.
And finally print the page.

Is this possible with just JS or is more required?

09-26-2005, 07:13 PM
HTML Goodies JavaScript Shopping Cart (http://www.htmlgoodies.com/beyond/javascript/article.php/3471331)

This tutorial uses a JavaScript shopping cart. I've actually used this code and tested it. It works fine, but requires you to set up your website using frames. I modified it so that it would work with an iframe. Now, it says it uses cookies for the shopping cart, but it really doesn't. The only time it uses a cookie is after a user submits the order, the thank you page asks the user to click on a certain link if they want their shipping address to be automatically filled out if they ever come back to it. The actual shopping cart is an object array that is kept in the parent frame while you navigate and order in the child frames. That way, information is just held in the array in the parent that is never closed, since navigation stays in the child frames. Of course, once the browser is closed, all information is lost (except for shipping details if that was stored earlier in the cookie). You may have to play around with the script if you find it not working correctly, because I was a bit disappointed to see that the script was written a bit sloppy, and once I cleaned it up, it began to work.


09-26-2005, 10:55 PM
I saw lots of problems with that script so I wrote my own version from scratch that works similarly and has all the proper processing included to handle the user typing to overtype values or use the back button etc that the one at HTML Goodies stuffs up on. You can see how it works and get a copy from at http://www.felgall.com/jstip39.htm