Exemplo n.º 1
0
 /**
  * @param Sale\ShipmentCollection $shipmentCollection
  *
  * @return Sale\Shipment
  * @throws Main\ArgumentNullException
  */
 public static function createShipmentFromShipmentSystem(Sale\ShipmentCollection $shipmentCollection)
 {
     $shipment = null;
     /** @var Sale\Shipment $systemShipment */
     $systemShipment = $shipmentCollection->getSystemShipment();
     if ($systemShipment->getDeliveryId() > 0) {
         /** @var Sale\Shipment $shipment */
         $shipment = static::getShipmentByDeliveryId($shipmentCollection, $systemShipment->getDeliveryId());
         if (!$shipment) {
             if ($service = Sale\Delivery\Services\Manager::getService($systemShipment->getDeliveryId())) {
                 /** @var Sale\Shipment $shipment */
                 $shipment = $shipmentCollection->createItem($service);
                 $shipment->setField('DELIVERY_NAME', $service->getName());
             }
         }
     }
     return $shipment;
 }
Exemplo n.º 2
0
 /**
  * @return ShipmentCollection|static
  */
 public function loadShipmentCollection()
 {
     return ShipmentCollection::load($this);
 }
Exemplo n.º 3
0
 /**
  * increase in the quantity of product if the reservation is disabled
  * @param ShipmentCollection $shipmentCollection
  * @param array $shipmentReserveList
  */
 public static function increaseProductQuantity(ShipmentCollection $shipmentCollection, array $shipmentReserveList = array())
 {
     $order = $shipmentCollection->getOrder();
     $options = array('ORDER_DEDUCTED' => $order->isShipped());
     $shipmentReserveListKeys = array_keys($shipmentReserveList);
     foreach ($shipmentCollection as $shipmentKey => $shipment) {
         if (!in_array($shipment->getId(), $shipmentReserveListKeys)) {
             unset($shipmentCollection[$shipmentKey]);
         }
     }
     foreach ($shipmentCollection as $shipment) {
         $basketProviderList = static::getProviderBasketFromShipment($shipment);
         $productList = static::getProductListFromBasketProviderList($basketProviderList);
         if (!empty($basketProviderList)) {
             foreach ($basketProviderList as $provider => $providerBasketItemList) {
                 $shipmentReserveListData = array();
                 if (!empty($shipmentReserveList) && !empty($shipmentReserveList[$shipment->getId()]) && is_array($shipmentReserveList[$shipment->getId()])) {
                     $shipmentReserveListData = $shipmentReserveList[$shipment->getId()];
                 }
                 $result = $provider::increaseProductQuantity($providerBasketItemList, $productList, $shipmentReserveListData, $options);
             }
         }
     }
 }