Like the other major samples we have written in this book, space and instructional constraints mean that we cannot implement absolutely everything we would imagine a good ecommerce system should have.
A truly wonderful way to see how code works and learn how PHP works is to try to write some improvements to the system on your own. To help encourage this, we have come up with a small list of exercises, or projects, that you might implement for this sample to improve it and learn more about its workings.
Skip Shipping Info
Users currently have to enter both billing and shipping information individually. Users commonly, however, want to enter the same values for both of them. An exercise would be to modify the shipinfo.php page to let users indicate that they just want to use their billing address as the shipping address.
Post Order Processing
The store currently does nothing after an order has successfully completed, waiting for somebody to come along and look for unfilled orders in the database. A useful improvement to this system would be to send somebody an e-mail indicating that a new order has been received, preferably with information about that order in the e-mail sent. Otherwise, data could be sent to a printer or otherwise communicated to the administrators.
After an order is filled, there is currently no way for the store owners to indicate this in the database. It would be nice to add an admin page (with its own means of authentication) via which an administrator could enter an order number and indicate that it has been filled.
Order Status/Cancel Order
When users submit an order today, there is no way for them to see the status of that order later or cancel it outright. As an exercise, we could add pages to let users see the status of their order (protected by their e-mail address and password, of course) and cancel it if it had not yet been filled.