public function __construct(Order $order) { $this->setId(); $this->setCreated(); $this->catalogPromotions = new ArrayCollection(); $this->productQuantityDiscounts = new ArrayCollection(); $this->orderItemOptionProducts = new ArrayCollection(); $this->orderItemOptionValues = new ArrayCollection(); $this->orderItemTextOptionValues = new ArrayCollection(); $this->attachments = new ArrayCollection(); $this->order = $order; $order->addOrderItem($this); }
/** * @param UuidInterface $orderId * @param User $user * @param Cart $cart * @param CartCalculatorInterface $cartCalculator * @param string $ip4 * @return Order */ public static function fromCart(UuidInterface $orderId, User $user, Cart $cart, CartCalculatorInterface $cartCalculator, $ip4) { $order = new Order($orderId); $order->setIp4($ip4); foreach ($cart->getCartItems() as $item) { $order->addOrderItem($item->getOrderItem($order, $cartCalculator->getPricing())); } foreach ($cart->getCoupons() as $coupon) { $order->addCoupon($coupon); } $order->setUser($user); $order->setTaxRate($cart->getTaxRate()); $order->setShipmentRate($cart->getShipmentRate()); $order->setTotal($cart->getTotal($cartCalculator)); return $order; }
public function testAddShipmentChangesOrderStatusToPartiallyShipped() { $orderItem = $this->dummyData->getOrderItem(); $orderItem->setQuantity(2); $shipment = $this->dummyData->getShipment(); $this->dummyData->getShipmentItem($shipment, $orderItem, 1); $order = new Order(); $order->addOrderItem($orderItem); $this->assertFalse($order->getStatus()->isPartiallyShipped()); $order->addShipment($shipment); $this->assertTrue($order->getStatus()->isPartiallyShipped()); }