This cost is simply added to the cost of the order. This is the reason why, in
Chapter 16, we included a shipping_region table??”its use will soon become apparent.
Implementing Tax and Shipping Charges
As expected, we need to make several modifications to TShirtShop to enable the tax and shipping
schemes outlined previously. We have two more database tables to add, tax and shipping,
as well as modifications to make to the orders table. We??™ll need to add new database functions
and make some modifications to existing ones. Some of the business tier classes need modifications
to account for these changes, and the presentation tier must include a method for users
to select a shipping method (the taxing scheme is selected automatically).
Ideally, we would clear the contents of the orders and order_detail tables or take into
consideration the fact that the old orders don??™t include tax and shipping charges, for which the
total amount will be calculated as $0.00.
So, let??™s get started.
CHAPTER 17 ?– STORING CUSTOMER ORDERS 560
Modifying the Data Tier
In this section, we??™ll add the new tables and modify the orders table and add or modify old
database stored procedures.
Exercise: Creating the Database Structures
1. Load phpMyAdmin, select the tshirtshop database, and open a new SQL query page.
2. Execute this code, which adds the shipping table to the tshirtshop database:
-- Create shipping table
CREATE TABLE `shipping` (
`shipping_id` INT NOT NULL AUTO_INCREMENT,
`shipping_type` VARCHAR(100) NOT NULL,
`shipping_cost` NUMERIC(10, 2) NOT NULL,
`shipping_region_id` INT NOT NULL,
PRIMARY KEY (`shipping_id`),
KEY `idx_shipping_shipping_region_id` (`shipping_region_id`)
);
3.
Pages:
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673