Add the following method to the OrderProcessor class in business/order_processor.php:
// Set order's ship date
public function SetDateShipped()
{
Orders::SetDateShipped($this->mOrderInfo['order_id']);
$this->mOrderInfo['shipped_on'] = date('Y-m-d');
}
Exercise: Sending E-mails to Customers and Suppliers
1. We need two methods to handle sending e-mails to customers and suppliers. Add the MailCustomer()
method to the OrderProcessor class:
// Send e-mail to the customer
public function MailCustomer($subject, $body)
{
$to = $this->mCustomerInfo['email'];
$headers = 'From: ' . CUSTOMER_SERVICE_EMAIL . "\r\n";
$result = mail($to, $subject, $body, $headers);
if ($result === false)
{
throw new Exception ('Unable to send e-mail to customer.');
}
}
2. Add the MailSupplier() method to the OrderProcessor class:
// Send e-mail to the supplier
public function MailSupplier($subject, $body)
{
$to = SUPPLIER_EMAIL;
$headers = 'From: ' . ORDER_PROCESSOR_EMAIL . "\r\n";
$result = mail($to, $subject, $body, $headers);
if ($result === false)
{
throw new Exception ('Unable to send e-mail to supplier.');
}
}
CHAPTER 18 ?– IMPLEMENTING THE ORDER PIPELINE: PART 1 589
Exercise: Retrieving Order Details and the Customer Address
1. We??™ll need to retrieve a string representation of the order and the customer address. For these tasks, add
the GetCustomerAddressAsString() method to the OrderProcessor class, located in business/
order_processor.
Pages:
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708