only for RuBoard - do not distribute or recompile Previous Section Next Section

Chapter 11. The Winestore Shopping Cart

In this chapter, we introduce the shopping cart developed for the online winestore. The shopping cart is typical of those used in online stores: the user can add items to the cart and manage the quantities of the different items. The solution we outline is scalable and practical. The cart data is stored in the winestore database tables, and only one session variable per user is required to track the cart's identity.

This chapter is the second of four that outline the complete winestore application. As discussed in Chapter 10, the descriptions of the scripts aren't comprehensive, and we assume you've read Chapter 2 to Chapter 9 as background. Also, we encourage you to install a local copy of the application and to view, edit, and use the scripts while reading this chapter.

We present here the four scripts that manage the shopping cart, a fifth script that produces the home page that includes the Hot New Wines panel, and a sixth script that manages redirection to other pages when the user clicks on buttons.

The scripts in this chapter perform the following functions:

Present the home page

Display the Hot New Wines panel based on the examples developed in Chapter 4 and Chapter 5

View the shopping cart

Query the database and display the contents of the user's shopping cart

Add items to the cart

Add a quantity of a specific wine to the user's shopping cart

Empty the cart

Delete all the items in the cart and remove the cart

Update quantities

Manage changes to the number of bottles of wines in the cart, including deletion of one or more wines

Process button clicks and redirect the browser

Manage the redirections required when the user presses the different buttons on each of the winestore pages

As with the other modules in the winestore, the shopping cart isn't a production system. The scripts presented here illustrate the practice of developing a web database application. Techniques shown include database interactivity, concurrency management, using sessions, and one- and two-component querying.

only for RuBoard - do not distribute or recompile Previous Section Next Section