Home arrow Ruby-on-Rails arrow Shopping Cart Implementation

Shopping Cart Implementation

Continuing our series on setting up an online bookstore with Ruby-on-Rails, this two-part tutorial explains how to implement the shopping cart. It is excerpted from chapter five of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 13
May 28, 2010
  1. · Shopping Cart Implementation
  2. · Setting Up the Shopping Cart
  3. · Creating the Models
  4. · Modifying the Controller

print this article

Shopping Cart Implementation
(Page 1 of 4 )

In the previous chapter, we built the general interface for Emporium. That’s a good start for an online store, but it doesn’t bring George any revenues. Now it’s time for us to take the next step toward a working e-commerce site: create a shopping cart where customers can drag all the interesting books they find—and preferably a few more.

A shopping cart is also a perfect match for taking advantage of Ajax to provide shoppers with a snappier and more responsive user interface. In this chapter, we will show you how to fully harness the power of Rails Ajax helpers to build a lightning-fast shopping cart, but we’ll also make sure that that it works on older browsers that don’t support JavaScript.

Getting the Shopping Cart Requirements

Again, Jill, George’s faithful customer, plays the main role in our user stories for this sprint:

  1. Add items to the cart: The most important shopping cart feature of any e-commerce application is the ability to add items to the cart. If building up a heaping shopping cart is easy, that will have a positive effect on the cash flow.
  2. Remove items from the cart: No matter how badly George wants Jill to buy all the books she inadvertently added to the cart, that’s just not how you make customers happy. 
  3. Clear the cart: Sometimes Jill goes totally bonkers. She just can’t help adding every book she runs into to the shopping cart. But then she remembers she is on a pension, not on a 100-foot yacht, and just wants to clean up the darn thing. So, we need to make it possible to empty the shopping cart with a single stroke.

The last user story to implement for a shopping cart is check out—the ultimate goal of a web shopping tour. Checking out is a bit more complicated than the other user stories, so we’re going to tackle it separately in Chapter 9. There, we’ll also cover how to integrate with credit card payment gateways.

blog comments powered by Disqus

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials