public function __construct(CartItemOptionValue $cartItemOptionValue, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $cartItemOptionValue;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = new CartItemOptionValueDTO();
     $this->setId();
     $this->setTime();
     $this->entityDTO->optionValue = $this->dtoBuilderFactory->getOptionValueDTOBuilder($this->entity->getOptionValue())->withAllData()->build();
 }
 public function testCreate()
 {
     $cartItem = $this->dummyData->getCartItem();
     $optionValue = $this->dummyData->getOptionValue();
     $optionValue->setSku('MD');
     $optionValue->setShippingWeight(6);
     $cartItemOptionValue = new CartItemOptionValue();
     $cartItemOptionValue->setOptionValue($optionValue);
     $cartItemOptionValue->setCartItem($cartItem);
     $this->assertSame('MD', $cartItemOptionValue->getSku());
     $this->assertSame(6, $cartItemOptionValue->getShippingWeight());
     $this->assertTrue($cartItemOptionValue->getPrice() instanceof Price);
     $this->assertSame($optionValue, $cartItemOptionValue->getOptionValue());
     $this->assertSame($cartItem, $cartItemOptionValue->getCartItem());
 }
Example #3
0
 public function addCartItemOptionValue(CartItemOptionValue $cartItemOptionValue)
 {
     $cartItemOptionValue->setCartItem($this);
     $this->cartItemOptionValues[] = $cartItemOptionValue;
 }
Example #4
0
 public function getCartItemOptionValue(OptionValue $optionValue = null)
 {
     if ($optionValue === null) {
         $optionValue = $this->getOptionValue();
     }
     $cartItemOptionValue = new CartItemOptionValue();
     $cartItemOptionValue->setOptionValue($optionValue);
     return $cartItemOptionValue;
 }
Example #5
0
 /**
  * @param UuidInterface $cartItemId
  * @param UuidInterface[] $optionValueIds
  * @throws EntityNotFoundException
  */
 public function addItemOptionValues(UuidInterface $cartItemId, array $optionValueIds)
 {
     $optionValues = $this->optionValueRepository->getAllOptionValuesByIds($optionValueIds);
     $cartItem = $this->cartRepository->getItemById($cartItemId);
     $cart = $cartItem->getCart();
     foreach ($optionValues as $optionValue) {
         $cartItemOptionValue = new CartItemOptionValue();
         $cartItemOptionValue->setOptionValue($optionValue);
         $cartItem->addCartItemOptionValue($cartItemOptionValue);
     }
     $this->cartRepository->update($cart);
 }