Beispiel #1
0
 protected function getOrders()
 {
     if (!isset($this->params['customer_token'])) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_NO_CUSTOMER_TOKEN);
     }
     if (!isset($this->params['customer_language'])) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_NO_CUSTOMER_LANGUAGE);
     }
     if (empty($this->response)) {
         $this->response = new ShopgatePluginApiResponseAppJson($this->trace_id);
     }
     $orders = $this->plugin->getOrders($this->params['customer_token'], $this->params['customer_language'], isset($this->params['limit']) ? $this->params['limit'] : 10, isset($this->params['offset']) ? $this->params['offset'] : 0, isset($this->params['order_date_from']) ? $this->params['order_date_from'] : '', isset($this->params['sort_order']) ? $this->params['sort_order'] : 'created_desc');
     if (!is_array($orders)) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_WRONG_RESPONSE_FORMAT, 'Plugin Response: ' . var_export($orders, true));
     }
     $resOrders = array();
     foreach ($orders as $order) {
         if (!$order instanceof ShopgateExternalOrder) {
             throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_API_WRONG_RESPONSE_FORMAT, 'Plugin Response: ' . var_export($orders, true));
         }
         $resOrders[] = $order->toArray();
     }
     $this->responseData['orders'] = $resOrders;
 }