コード例 #1
0
 protected function processRecord(CustomerOrder $order)
 {
     $order->processMass_history = new OrderHistory($order, SessionUser::getUser());
     switch ($this->getAction()) {
         case 'setNew':
             $status = CustomerOrder::STATUS_NEW;
             break;
         case 'setProcessing':
             $status = CustomerOrder::STATUS_PROCESSING;
             break;
         case 'setAwaitingShipment':
             $status = CustomerOrder::STATUS_AWAITING;
             break;
         case 'setShipped':
             $status = CustomerOrder::STATUS_SHIPPED;
             break;
         case 'setReturned':
             $status = CustomerOrder::STATUS_RETURNED;
             break;
         case 'setUnfinalized':
             $order->isFinalized->set(0);
             break;
         case 'setCancel':
             $order->cancel();
             break;
         case 'setFinalized':
             if (!$order->isFinalized->get() && $order->user->get()) {
                 $order->finalize();
             }
             break;
     }
     if (isset($status) && $status != $order->status->get()) {
         $order->setStatus($status);
         $this->params['controller']->sendStatusNotifyEmail($order);
     }
 }
コード例 #2
0
ファイル: TransactionApi.php プロジェクト: saiber/www
 protected function finalizeOrder(CustomerOrder $customer_order, User $user)
 {
     $user->load();
     /*if (!count($customer_order->getShipments()))
       {
           throw new Exception('No shipments in order');
       }*/
     $newOrder = $customer_order->finalize();
     $orderArray = $customer_order->toArray(array('payments' => true));
     // send order confirmation email
     if ($this->application->config->get('EMAIL_NEW_ORDER')) {
         $email = new Email($this->application);
         $email->setUser($user);
         $email->setTemplate('order.new');
         $email->set('order', $orderArray);
         $email->send();
     }
     // notify store admin
     if ($this->application->config->get('NOTIFY_NEW_ORDER')) {
         $email = new Email($this->application);
         $email->setTo($this->application->config->get('NOTIFICATION_EMAIL'), $this->application->config->get('STORE_NAME'));
         $email->setTemplate('notify.order');
         $email->set('order', $orderArray);
         $email->set('user', $user->toArray());
         $email->send();
     }
     // if user hasn't wish list items order->finalize() will return null, saving null with SessionOrder causes fatal error!
     if ($newOrder instanceof CustomerOrder) {
         return true;
     }
     return false;
 }