コード例 #1
0
 function it_adds_new_inventory_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, ArrayCollection $shipments, InventoryUnitInterface $inventoryUnit, InventoryUnitInterface $inventoryUnitWithoutShipment)
 {
     $shipments->first()->willReturn($shipment)->shouldBeCalled();
     $inventoryUnit->getShipment()->willReturn($shipment);
     $order->getInventoryUnits()->willReturn(array($inventoryUnit, $inventoryUnitWithoutShipment));
     $order->getShipments()->willReturn($shipments)->shouldBeCalled();
     $shipment->addItem($inventoryUnitWithoutShipment)->shouldBeCalled();
     $shipment->addItem($inventoryUnit)->shouldNotBeCalled();
     $this->createShipment($order);
 }
コード例 #2
0
ファイル: ShipmentFactory.php プロジェクト: bcremer/Sylius
 /**
  * {@inheritdoc}
  */
 public function createShipment(OrderInterface $order)
 {
     $shipment = $order->getShipments()->first();
     if (!$shipment) {
         $shipment = $this->shipmentRepository->createNew();
         $order->addShipment($shipment);
     }
     foreach ($order->getInventoryUnits() as $inventoryUnit) {
         if (null === $inventoryUnit->getShipment()) {
             $shipment->addItem($inventoryUnit);
         }
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function createForOrder(OrderInterface $order)
 {
     if ($order->hasShipments()) {
         $shipment = $order->getShipments()->first();
     } else {
         $shipment = $this->shipmentFactory->createNew();
         $order->addShipment($shipment);
     }
     foreach ($order->getInventoryUnits() as $inventoryUnit) {
         if (null === $inventoryUnit->getShipment()) {
             $shipment->addItem($inventoryUnit);
         }
     }
 }
コード例 #4
0
ファイル: LoadOrdersData.php プロジェクト: Avazanga1/Sylius
 protected function createShipment(OrderInterface $order)
 {
     /* @var $shipment ShipmentInterface */
     $shipment = $this->getShipmentRepository()->createNew();
     $shipment->setMethod($this->getReference('Sylius.ShippingMethod.UPS Ground'));
     $shipment->setState($this->getShipmentState());
     foreach ($order->getInventoryUnits() as $item) {
         $shipment->addItem($item);
     }
     $order->addShipment($shipment);
 }