1,105,556 Community Members

How to make shopping cart with JS

Member Avatar
Martin C++
Junior Poster in Training
75 posts since Aug 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
AleMonteiro
Master Poster
758 posts since Aug 2010
Reputation Points: 115 [?]
Q&As Helped to Solve: 143 [?]
Skill Endorsements: 29 [?]
 
0
 

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/

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article