Chapter 19. Ordering and Shipping at the Online Winestore

This chapter is the fourth of five that outline the complete winestore application. In this chapter, we complete our description of the shopping components of the winestore by explaining the ordering and shipping modules. The ordering module collects and validates credit card details and manages the conversion of the shopping cart discussed in Chapter 18 to an order. In this process, the module manages the most complex database interactions in the winestore and uses locking to address concurrency problems.

The scripts discussed in this chapter perform the following functions:


Collect credit card and delivery details

Collects a credit card number, expiration date, and optional delivery instructions. These are validated using the techniques discussed in Chapter 9.


Finalize orders

Converts a shopping cart to an order and manages the sale of wine from the inventory table. This illustrates complex database processing that requires the locking techniques discussed in Chapter 8.


Email receipts

Sends a confirmation email to the user using the PEAR Mail package and a template that illustrates how the templates described in Chapter 7 can be used for non-HTML applications. Code that uses the PHP mail( ) library function is also included, but is not enabled by default.


HTML order receipts

Completes the ordering process with an HTML receipt that avoids the reload problem discussed in Chapter 6.