We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,235 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to make shopping cart with JS

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

2
Contributors
1
Reply
2 Hours
Discussion Span
5 Months Ago
Last Updated
3
Views
Martin C++
Junior Poster in Training
69 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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/

AleMonteiro
Master Poster
752 posts since Aug 2010
Reputation Points: 129
Solved Threads: 140
Skill Endorsements: 23

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0751 seconds using 2.76MB