public function testCreate()
 {
     $pricing = $this->dummyData->getPricing();
     $cartItem = $this->dummyData->getCartItem();
     $optionProduct = $this->dummyData->getOptionProduct();
     $optionProduct->getProduct()->setSku('LAA');
     $optionProduct->getProduct()->setShippingWeight(6);
     $cartItemOptionProduct = new CartItemOptionProduct();
     $cartItemOptionProduct->setOptionProduct($optionProduct);
     $cartItemOptionProduct->setCartItem($cartItem);
     $this->assertSame('LAA', $cartItemOptionProduct->getSku());
     $this->assertSame(6, $cartItemOptionProduct->getShippingWeight());
     $this->assertTrue($cartItemOptionProduct->getPrice($pricing) instanceof Price);
     $this->assertSame($optionProduct, $cartItemOptionProduct->getOptionProduct());
     $this->assertSame($cartItem, $cartItemOptionProduct->getCartItem());
 }
Beispiel #2
0
 public function addCartItemOptionProduct(CartItemOptionProduct $cartItemOptionProduct)
 {
     $cartItemOptionProduct->setCartItem($this);
     $this->cartItemOptionProducts[] = $cartItemOptionProduct;
 }
Beispiel #3
0
 public function getCartItemOptionProduct(OptionProduct $optionProduct = null)
 {
     if ($optionProduct === null) {
         $optionProduct = $this->getOptionProduct();
     }
     $cartItemOptionProduct = new CartItemOptionProduct();
     $cartItemOptionProduct->setOptionProduct($optionProduct);
     return $cartItemOptionProduct;
 }
 /**
  * @return static
  */
 public function withOptionProduct(PricingInterface $pricing)
 {
     $this->entityDTO->optionProduct = $this->dtoBuilderFactory->getOptionProductDTOBuilder($this->entity->getOptionProduct())->withOption()->withProduct($pricing)->build();
     return $this;
 }
Beispiel #5
0
 /**
  * @param UuidInterface $cartItemId
  * @param UuidInterface[] $optionProductIds
  * @throws EntityNotFoundException
  */
 public function addItemOptionProducts(UuidInterface $cartItemId, array $optionProductIds)
 {
     $optionProducts = $this->optionProductRepository->getAllOptionProductsByIds($optionProductIds);
     $cartItem = $this->cartRepository->getItemById($cartItemId);
     $cart = $cartItem->getCart();
     foreach ($optionProducts as $optionProduct) {
         $cartItemOptionProduct = new CartItemOptionProduct();
         $cartItemOptionProduct->setOptionProduct($optionProduct);
         $cartItem->addCartItemOptionProduct($cartItemOptionProduct);
     }
     $this->cartRepository->update($cart);
 }