/**
  * @return static
  */
 public function withItems()
 {
     foreach ($this->entity->getOrderItems() as $orderItem) {
         $this->entityDTO->orderItems[] = $this->dtoBuilderFactory->getOrderItemDTOBuilder($orderItem)->withFullData()->build();
     }
     return $this;
 }
Beispiel #2
0
 public function testCreateDefaults()
 {
     $order = new Order();
     $this->assertTrue($order->getId() instanceof UuidInterface);
     $this->assertTrue($order->getCreated() instanceof DateTime);
     $this->assertSame(null, $order->getExternalId());
     $this->assertSame(null, $order->getReferenceNumber());
     $this->assertSame('0.0.0.0', $order->getIp4());
     $this->assertSame(0, $order->totalItems());
     $this->assertSame(0, $order->totalQuantity());
     $this->assertTrue($order->getStatus()->isPending());
     $this->assertSame(null, $order->getTotal());
     $this->assertSame(null, $order->getShippingAddress());
     $this->assertSame(null, $order->getBillingAddress());
     $this->assertSame(null, $order->getUser());
     $this->assertSame(null, $order->getShipmentRate());
     $this->assertSame(null, $order->getTaxRate());
     $this->assertSame(null, $order->getOrderItem(0));
     $this->assertSame(0, count($order->getOrderItems()));
     $this->assertSame(0, count($order->getCoupons()));
     $this->assertSame(0, count($order->getPayments()));
     $this->assertSame(0, count($order->getProducts()));
     $this->assertSame(0, count($order->getShipments()));
 }
Beispiel #3
0
 private function reserveProductsFromInventory(Order $order)
 {
     foreach ($order->getOrderItems() as $orderItem) {
         $this->inventoryService->reserveProduct($orderItem->getProduct(), $orderItem->getQuantity());
         foreach ($orderItem->getOrderItemOptionProducts() as $orderItemOptionProduct) {
             $this->inventoryService->reserveProduct($orderItemOptionProduct->getOptionProduct()->getProduct(), $orderItem->getQuantity());
         }
     }
 }