Jump to content
Larry Ullman's Book Forums

Shopping Cart- Help


Recommended Posts

You could connect the "Add to Cart" button to an ajax function so when it was clicked it added the item to your shopping cart table in the table that way you would still stay on the product page. But anyway if this solution you are going to make is working with Sessions only the customer would at least need to log into the site every time they needed to purchase something right otherwise a cookie will definitely be required? (You need either an customer account on your site or a cookie stored locally on the customers computer otherwise reference to this customer and order would be lost).

  • Upvote 1
Link to comment
Share on other sites

kimk84, hello and welcome to the forums.

 

You can accomplish what you want with JavaScript, yes.

For example, you could set up onclick event handlers for the "Add to Cart" buttons for the items on a page, and when a user clicks on one of those buttons, store that information in a local JS object/array.

 

Then, you could iterate through the object/array and display all the pertinent information in a hidden div that you then show.

Based on how complex you want to make this/how the rest of the system is functioning, you may also need to incorporate some Ajax as well.

 

In addition, you can of course use sessions instead of cookies, but please note that sessions are not accessible via JS, so you will have to use Ajax to update the session each time if you don't want to perform a new page request/refresh.

 

I know that's a vague answer, but I'm not sure what all you're trying to accomplish.

Good luck, and please ask any follow-up questions if you have them.

Thanks.

Link to comment
Share on other sites

You can also use the JQuery javascript framework to aid your solution, using JQuery provides a faster way to get the same result as using core javascript. The advantage of JQuery is it provides a cross browser solution that works on all browsers, this can save you the time of hacking away with your regular javascript. However you will need basic knowledge of javascript in order to use JQuery successfully.

 

http://jquery.com/

 

The majority of websites are using this now as time is money in business.

Link to comment
Share on other sites

 Share

×
×
  • Create New...