As you can see from the title I am interested in making a shopping cart with javascript. What it should do is allow a client to add/remove products from the cart. Increase the quantity and have a visual overview of his cart. When he is finished he would go to the checkout where PHP takes care of submitting the order. The problem is I have very little experience with javascript so I was hoping that someone could help me. Tutorials and all other reading material that might help accomplish this task is welcomed. I was thinking of using cookies to store the cart info. Is that a good idea? How to do this if it is ? I understand JS isnt very secure for handlig money but if I pass all the prices to the script with PHP then I was guessing that it's secure after all. Am I right about that?

Thanks in advance

Last things first... you shouldn't relly on JS to calculate the final price. You can use JS to calculate and show the price to the user, but once you send the selected products to your PHP script you should use the prices from the database. What I mean is, don't post the price from JS to your PHP and use it to commit the transaction.

About storing the products, if your shopping cart will have more then one page you could store in the session in PHP. If it's only one page, you don't need it.
I don't think cookies are a good option because it has very low size limits (4kb I guess, but not sure)

About the UI, I suggest you take a look at jQuery UI Droppable examples:
http://jqueryui.com/droppable/#shopping-cart

http://jqueryui.com/droppable/#photo-manager

And googling a little bit I suggest you take a look at this two links:
http://dzineblog.com/2010/10/10-amazing-collections-of-ajax-shopping-cart.html

http://simplecartjs.org/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.