Example #1
0
 /**
  * Notifies the customer of their delivery.
  *
  * @param \IocExample\Model\Customer $customer
  * @param \IocExample\Model\Order $order
  * @return void
  */
 public function notifyCustomerOfDelivery(Customer $customer, Order $order)
 {
     $this->_mailer->setFrom('*****@*****.**', 'Grumpy Baby Orders');
     $this->_mailer->setSubject('Order #' . $order->getId() . ' out for Delivery');
     $this->_mailer->setBodyText('Your order is being shipped!');
     $this->_mailer->addTo($customer->getEmail(), $customer->getName());
     $this->_mailer->send();
 }
Example #2
0
    /**
     * Fetches a single order by its unique Id.
     *
     * @param  int $id
     * @return Order
     */
    public function getById($id)
    {
        try {
            $result = $this->_database->fetchOne(
                'SELECT o.*,c.* FROM order o INNER JOIN customer c ON o.customer_id = c.id WHERE o.id = ?',
                array($id));

            if ($result == null) throw new \Exception("Could not find order with id " . $id);
            $customer = new Customer();
            $customer->setName($result['name']);
            $customer->setAddress1($result['address_1']);
            $customer->setAddress2($result['address_2']);
            $customer->setCity($result['city']);
            $customer->setState($result['state']);
            $customer->setPostalCode($result['postal_code']);
            $customer->setCellphone($result['cell_phone']);
            $customer->setEmail($result['email']);
            $customer->setCallbackUrl($result['callback_url']);
            $order = new Order();
            $order->setId($id);
            $order->setCustomer($customer);

            return $order;
        }
        catch (\Exception $e)
        {
            throw $e;
        }
    }