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
The scripts discussed in this chapter perform the following functions:
|
19.1 Code OverviewThe ordering and shipping processes are implemented in the following scripts: order/order-step1.php , order/order-step2.php , order/order-step3.php , order/order-step4.php, and order/receipt.php . The scripts work with the orders , items , and inventory tables discussed in Chapter 18: CREATE TABLE orders ( cust_id int(5) NOT NULL, order_id int(5) NOT NULL, date timestamp(12), instructions varchar(128), creditcard char(16), expirydate char(5), PRIMARY KEY (cust_id,order_id) ) type=MyISAM; CREATE TABLE items ( cust_id int(5) NOT NULL, order_id int(5) NOT NULL, item_id int(3) NOT NULL, wine_id int(4) NOT NULL, qty int(3), price float(5,2), date timestamp(12), PRIMARY KEY (cust_id,order_id,item_id) ) type=MyISAM; CREATE TABLE inventory ( wine_id int(5) NOT NULL, inventory_id int(3) NOT NULL, on_hand int(5) NOT NULL, cost decimal(5,2) NOT NULL, date_added date, PRIMARY KEY (wine_id,inventory_id) ) type=MyISAM; The orders table includes the attributes instructions , creditcard , and expirydate that were omitted from our discussions in Chapter 18. These are used to store delivery and credit card details for each order that's shipped to a customer.
The script
order/order-step1.php
Figure 19-1. The form that collects credit card and delivery details
The credit card details are
Step three of the process, which is implemented in the script
order/order-step3.php,
After the order has been finalized, two receipts are produced. The first is an email receipt output by the script order/order-step4.php . The email is produced using the same template approach used to prepare a HTML page, and sent with the PEAR Mail package; we also include alternative code that uses the PHP mail( ) library function. The script then redirects to the final script in this chapter, order/receipt.php , that shows the user their receipt as an HTML page as shown in Figure 19-2. Figure 19-2. An HTML order receipt
|