The business tier part for the componentized template admin_order_details is very simple and consists
of the following methods that you need to add to the Orders class inside of the business/orders.php file:
// Gets the details of a specific order
public static function GetOrderInfo($orderId)
{
// Build the SQL query
$sql = 'CALL orders_get_order_info(:order_id)';
// Build the parameters array
$params = array (':order_id' => $orderId);
// Execute the query and return the results
return DatabaseHandler::GetRow($sql, $params);
}
// Gets the products that belong to a specific order
public static function GetOrderDetails($orderId)
{
// Build the SQL query
$sql = 'CALL orders_get_order_details(:order_id)';
// Build the parameters array
$params = array (':order_id' => $orderId);
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
// Updates order details
public static function UpdateOrder($orderId, $status, $comments,
$customerName, $shippingAddress, $customerEmail)
{
// Build the SQL query
$sql = 'CALL orders_update_order(:order_id, :status, :comments,
:customer_name, :shipping_address, :customer_email)';
// Build the parameters array
$params = array (':order_id' => $orderId,
':status' => $status,
':comments' => $comments,
':customer_name' => $customerName,
':shipping_address' => $shippingAddress,
':customer_email' => $customerEmail);
// Execute the query
DatabaseHandler::Execute($sql, $params);
}
CHAPTER 14 ?– ACCEPTING CUSTOMER ORDERS 455
6.
Pages:
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574