예제 #1
0
 public function updateOrder(ShopgateOrder $order)
 {
     $shopgateOrder = PSShopgateOrder::instanceByOrderNumber($order->getOrderNumber());
     if (!Validate::isLoadedObject($shopgateOrder)) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_ORDER_NOT_FOUND, 'Order not found', true);
     }
     $order_states = array();
     if ($order->getUpdatePayment() && $order->getIsPaid()) {
         array_push($order_states, $this->getOrderStateId('PS_OS_PAYMENT'));
     }
     if ($order->getUpdateShipping() && !$order->getIsShippingBlocked()) {
         array_push($order_states, $this->getOrderStateId('PS_OS_PREPARATION'));
     }
     if (count($order_states)) {
         $ps_order = new Order($shopgateOrder->id_order);
         foreach ($order_states as $id_order_state) {
             if (version_compare(_PS_VERSION_, '1.4.1.0', '<')) {
                 $history = new OrderHistory();
                 $history->id_order = (int) $shopgateOrder->id_order;
                 $history->changeIdOrderState((int) $id_order_state, (int) $shopgateOrder->id_order);
             } else {
                 $ps_order->setCurrentState($id_order_state);
             }
         }
     }
     return array('external_order_id' => $shopgateOrder->id_order, 'external_order_number' => $shopgateOrder->id_order);
 }