private function shipmentInfo($response)
 {
     $order = CustomerOrder::getInstanceById($this->request->get('id'), true, true);
     $order->loadAll();
     $order->getCoupons();
     $products = ARSet::buildFromArray($order->getOrderedItems())->extractReferencedItemSet('product', 'ProductSet');
     $variations = $products->getVariationMatrix();
     $form = $this->createShipmentForm();
     $form->setData(array('orderID' => $order->getID()));
     $shipments = $order->getShipments();
     $zone = $order->getDeliveryZone();
     $taxZone = $order->getTaxZone();
     $statuses = array(Shipment::STATUS_NEW => $this->translate('_shipping_status_new'), Shipment::STATUS_PROCESSING => $this->translate('_shipping_status_pending'), Shipment::STATUS_AWAITING => $this->translate('_shipping_status_awaiting'), Shipment::STATUS_SHIPPED => $this->translate('_shipping_status_shipped'), Shipment::STATUS_RETURNED => $this->translate('_shipping_status_returned'));
     $subtotalAmount = 0;
     $shippingAmount = 0;
     $taxAmount = 0;
     $itemIDs = $shipmentsArray = array();
     $shipableShipmentsCount = 0;
     foreach ($shipments as $shipment) {
         $subtotalAmount += $shipment->amount->get();
         $shippingAmount += $shipment->shippingAmount->get();
         $taxAmount += $shipment->taxAmount->get();
         $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());
             if (isset($shipmentsArray[$shipment->getID()]['serviceID'])) {
                 $shipmentsArray[$shipment->getID()]['ShippingService']['ID'] = $shipmentsArray[$shipment->getID()]['serviceID'];
             }
         } else {
             if ($shipment->shippingService->get()) {
                 $shipmentsArray[$shipment->getID()]['ShippingService']['name_lang'] = $shipmentsArray[$shipment->getID()]['ShippingService']['name'];
             } else {
                 $shipmentsArray[$shipment->getID()]['ShippingService']['name_lang'] = $this->translate('_shipping_service_is_not_selected');
             }
         }
         if ($shipment->status->get() != Shipment::STATUS_SHIPPED && $shipment->isShippable()) {
             $shipableShipmentsCount++;
         }
         foreach ($shipment->getItems() as $item) {
             $itemIDs[] = $item->getID();
         }
     }
     $totalAmount = $subtotalAmount + $shippingAmount + $taxAmount;
     // $response = new ActionResponse();
     $response->set('orderID', $this->request->get('id'));
     $response->set('order', $order->toArray());
     $response->set('shippingServiceIsNotSelected', $this->translate('_shipping_service_is_not_selected'));
     $response->set('shipments', $shipmentsArray);
     $response->set('subtotalAmount', $subtotalAmount);
     $response->set('shippingAmount', $shippingAmount);
     $response->set('variations', $variations);
     if ($downloadable = $order->getDownloadShipment(false)) {
         $response->set('downloadableShipment', $downloadable->toArray());
     }
     $response->set('taxAmount', $taxAmount);
     $response->set('totalAmount', $totalAmount);
     $response->set('shipableShipmentsCount', $shipableShipmentsCount);
     $response->set('statuses', $statuses + array(-1 => $this->translate('_delete')));
     unset($statuses[3]);
     $response->set('statusesWithoutShipped', $statuses);
     $response->set('newShipmentForm', $form);
     $response->set('downloadCount', $this->getDownloadCounts($itemIDs));
     // load product options
     $response->set('allOptions', ProductOption::loadOptionsForProductSet($products));
     return $response;
 }
Esempio n. 2
0
 private function getItemOptions()
 {
     // load product options
     $products = array();
     foreach ($this->order->getOrderedItems() as $item) {
         $products[$item->getProduct()->getID()] = $item->getProduct();
     }
     $options = ProductOption::loadOptionsForProductSet(ARSet::buildFromArray($products));
     $moreOptions = $optionsArray = array();
     foreach ($this->order->getOrderedItems() as $item) {
         $productID = $item->getProduct()->getID();
         if (isset($options[$productID])) {
             $optionsArray[$item->getID()] = $this->getOptionsArray($options[$productID], $item, 'isDisplayedInCart');
             $moreOptions[$item->getID()] = $this->getOptionsArray($options[$productID], $item, 'isDisplayed');
         }
     }
     // are there any options that are available for customer to set, but not displayed right away?
     foreach ($moreOptions as &$options) {
         foreach ($options as $key => $option) {
             if ($option['isDisplayedInCart']) {
                 unset($options[$key]);
             }
         }
     }
     return array('visible' => $optionsArray, 'more' => $moreOptions);
 }
Esempio n. 3
0
 private function getItemResponse(OrderedItem $item)
 {
     $item->customerOrder->get()->load();
     $item->customerOrder->get()->loadItems();
     if ($image = $item->getProduct()->defaultImage->get()) {
         $image->load();
     }
     $this->application->getLocale()->translationManager()->loadFile('backend/Shipment');
     $response = new ActionResponse('item', $item->toArray());
     // load product options and variations
     $response->set('allOptions', ProductOption::loadOptionsForProductSet($item->getProduct()->getParent()->initSet()));
     $response->set('variations', $item->getProduct()->getParent()->initSet()->getVariationData($this->application));
     return $response;
 }