Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Is it possible to build a JS Shopping Cart w/out a database?

    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?

  • #2
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    HTML Goodies JavaScript Shopping Cart

    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.

    -Shane

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    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
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •