Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 21. Creating e-Commerce Sites > Building Shopping Carts in Spectra

Building Shopping Carts in Spectra

As discussed above, the shopping cart is the heart of an e-commerce application. It exists as a storage facility for items a user is interested in buying. Several different methodologies can be used to build a shopping cart in Spectra, one of which is in the following section.

Storing the Shopping Cart as a User Profile

A Shopping Cart is a collection of items that a user is purchasing. A Shopping Cart is related to a single user for a brief period of time and isn't persistent, such as a Book or an Author. It makes the most sense to store the Shopping Cart directly with the user. To create a Shopping Cart in Spectra, you can create a user preference that will hold it. That way, you can avoid the hassle of creating a Shopping Cart object for each user, securing it to that user, and deleting it when the transaction is complete. Also, if the Shopping Cart is stored as a preference instead of as a session variable, it will persist across several visits to the store, and the user can leave items in the cart until he chooses to remove or purchase them.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial