Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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.
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.