Пример #1
0
 private function getOrderShipments(CustomerOrder $order)
 {
     $order->loadItems();
     $shipments = $order->getShipments();
     $downloadable = $order->getDownloadShipment(false);
     if ($downloadable && count($shipments) == 1 && !count($downloadable->getItems())) {
         $downloadable = null;
     }
     $shipmentsArray = array();
     foreach ($shipments as $key => $shipment) {
         // one shipment is reserved for downloadable items
         if ($shipment === $downloadable || $shipment->isShipped()) {
             continue;
         }
         $shipmentsArray[$shipment->getID()] = $shipment->toArray();
         $rate = unserialize($shipment->shippingServiceData->get());
         if (is_object($rate)) {
             $rate->setApplication($this->application);
             $shipmentsArray[$shipment->getID()] = array_merge($shipmentsArray[$shipment->getID()], $rate->toArray());
             $shipmentsArray[$shipment->getID()]['ShippingService']['ID'] = $shipmentsArray[$shipment->getID()]['serviceID'];
         } else {
             $shipmentsArray[$shipment->getID()]['ShippingService']['name_lang'] = $this->translate('_shipping_service_is_not_selected');
         }
     }
     return $shipmentsArray;
 }