php. We must modify CreateOrder() in ShoppingCart to configure
tax and shipping for new orders as well.
CHAPTER 17 ?– STORING CUSTOMER ORDERS 563
Exercise: Updating the Business Tier
1. Modify the CreateOrder() method in business/shopping_cart.php as follows:
// Create a new order
public static function CreateOrder($customerId, $shippingId, $taxId)
{
// Build SQL query
$sql = 'CALL shopping_cart_create_order(:cart_id, :customer_id,
:shipping_id, :tax_id)';
// Build the parameters array
$params = array (':cart_id' => self::GetCartId(),
':customer_id' => $customerId,
':shipping_id' => $shippingId,
':tax_id' => $taxId);
// Execute the query and return the results
return DatabaseHandler::GetOne($sql, $params);
}
2. Add the GetShippingInfo() method to the Orders class in business/orders.php:
// Retrieves the shipping details for a given $shippingRegionId
public static function GetShippingInfo($shippingRegionId)
{
// Build the SQL query
$sql = 'CALL orders_get_shipping_info(:shipping_region_id)';
// Build the parameters array
$params = array (':shipping_region_id' => $shippingRegionId);
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
Modifying the Presentation Tier
Finally, we come to the presentation layer. In fact, due to the changes we??™ve made, the only
changes to make here are to the checkout and the orders administration pages.
Pages:
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677