/** * @param OrderItem $orderItem * @return ShipmentItem|null */ public function getShipmentItemForOrderItem(OrderItem $orderItem) { foreach ($this->shipmentItems as $shipmentItem) { if ($shipmentItem->getOrderItem()->getId() === $orderItem->getId()) { return $shipmentItem; } } return null; }
/** * @param OrderDTO $orderDTO * @return static */ public function withOrderDTO(OrderDTO $orderDTO = null) { if ($orderDTO === null) { $orderDTO = $this->dtoBuilderFactory->getOrderDTOBuilder($this->entity->getOrder())->build(); } $this->entityDTO->order = $orderDTO; return $this; }
public function getOrderItem(Order $order, PricingInterface $pricing) { $orderItem = new OrderItem($order); $orderItem->setProduct($this->getProduct()); $orderItem->setQuantity($this->getQuantity()); $orderItem->setPrice($this->getPrice($pricing)); foreach ($this->getCartItemOptionProducts() as $cartItemOptionProduct) { $orderItemOptionProduct = new OrderItemOptionProduct(); $orderItemOptionProduct->setOptionProduct($cartItemOptionProduct->getOptionProduct()); $orderItem->addOrderItemOptionProduct($orderItemOptionProduct); } foreach ($this->getCartItemOptionValues() as $cartItemTextOptionValue) { $orderItemOptionValue = new OrderItemOptionValue(); $orderItemOptionValue->setOptionValue($cartItemTextOptionValue->getOptionValue()); $orderItem->addOrderItemOptionValue($orderItemOptionValue); } foreach ($this->getCartItemTextOptionValues() as $cartItemTextOptionValue) { $orderItemTextOptionValue = new OrderItemTextOptionValue(); $orderItemTextOptionValue->setTextOption($cartItemTextOptionValue->getTextOption()); $orderItemTextOptionValue->setTextOptionValue($cartItemTextOptionValue->getTextOptionValue()); $orderItem->addOrderItemTextOptionValue($orderItemTextOptionValue); } return $orderItem; }
public function getOrderItemFull(Order $order) { if ($order === null) { $order = $this->getOrder(); } $product = $this->getProduct(); $product->enableAttachments(); $orderItem = new OrderItem($order); $orderItem->setProduct($product); $orderItem->setQuantity(1); $orderItem->setPrice($this->getPriceFull()); $orderItem->addOrderItemOptionProduct($this->getOrderItemOptionProduct()); $orderItem->addOrderItemOptionValue($this->getOrderItemOptionValue()); $orderItem->addOrderItemTextOptionValue($this->getOrderItemTextOptionValue()); $orderItem->addAttachment($this->getAttachment()); return $orderItem; }
private function isOrderItemFullyShipped(OrderItem $orderItem) { foreach ($this->getShipments() as $shipment) { if ($orderItem->isShipmentFullyShipped($shipment)) { return true; } } return false; }
private function lockOrderItemAttachments(OrderItem $orderItem) { foreach ($orderItem->getAttachments() as $attachment) { $this->lockAttachment($attachment); } }
public function testGetQuantityShippingWeight() { $product1 = $this->dummyData->getProduct(); $product1->setShippingWeight(1); $order = $this->dummyData->getOrder(); $orderItem = new OrderItem($order); $orderItem->setProduct($product1); $orderItem->setQuantity(2); $this->assertSame(1, $orderItem->getShippingWeight()); $this->assertSame(2, $orderItem->getQuantityShippingWeight()); $product2 = $this->dummyData->getProduct(); $product2->setShippingWeight(3); $optionProduct = $this->dummyData->getOptionProduct(null, $product2); $orderItemOptionProduct = $this->dummyData->getOrderItemOptionProduct($optionProduct); $orderItem->addOrderItemOptionProduct($orderItemOptionProduct); $orderItem->addOrderItemOptionProduct($orderItemOptionProduct); $this->assertSame(14, $orderItem->getQuantityShippingWeight()); $optionValue = $this->dummyData->getOptionValue(); $optionValue->setShippingWeight(5); $orderItemOptionValue = $this->dummyData->getOrderItemOptionValue($optionValue); $orderItem->addOrderItemOptionValue($orderItemOptionValue); $orderItem->addOrderItemOptionValue($orderItemOptionValue); $this->assertSame(17, $orderItem->getShippingWeight()); $this->assertSame(34, $orderItem->getQuantityShippingWeight()); }