public function testCreate() { $option = $this->dummyData->getOption(); $option->setName('Shirt Size'); $optionValue = $this->dummyData->getOptionValue($option); $optionValue->setSku('MD'); $optionValue->setName('Medium Shirt'); $orderItem = $this->dummyData->getOrderItem(); $orderItemOptionValue = new OrderItemOptionValue(); $orderItemOptionValue->setOptionValue($optionValue); $orderItemOptionValue->setOrderItem($orderItem); $this->assertSame('MD', $orderItemOptionValue->getSku()); $this->assertSame('Shirt Size', $orderItemOptionValue->getOptionName()); $this->assertSame('Medium Shirt', $orderItemOptionValue->getOptionValueName()); $this->assertSame($optionValue, $orderItemOptionValue->getOptionValue()); $this->assertSame($orderItem, $orderItemOptionValue->getOrderItem()); }
/** * @return static */ public function withOptionValue() { $this->entityDTO->optionValue = $this->dtoBuilderFactory->getOptionValueDTOBuilder($this->entity->getOptionValue())->withOption()->build(); 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 getOrderItemOptionValue(OptionValue $optionValue = null) { if ($optionValue === null) { $optionValue = $this->getOptionValue(); } $orderItemOptionValue = new OrderItemOptionValue(); $orderItemOptionValue->setOptionValue($optionValue); return $orderItemOptionValue; }
public function addOrderItemOptionValue(OrderItemOptionValue $orderItemOptionValue) { $orderItemOptionValue->setOrderItem($this); $this->orderItemOptionValues[] = $orderItemOptionValue; $this->setSku(); }