| @@ 43-58 (lines=16) @@ | ||
| 40 | $this->orderModifier = $orderModifier; |
|
| 41 | } |
|
| 42 | ||
| 43 | public function handle(PutOptionBasedConfigurableItemToCart $putConfigurableItemToCart) |
|
| 44 | { |
|
| 45 | /** @var OrderInterface $cart */ |
|
| 46 | $cart = $this->cartRepository->findOneBy(['tokenValue' => $putConfigurableItemToCart->orderToken()]); |
|
| 47 | ||
| 48 | Assert::notNull($cart, 'Cart has not been found'); |
|
| 49 | ||
| 50 | /** @var ProductInterface $product */ |
|
| 51 | $product = $this->productRepository->findOneByCode($putConfigurableItemToCart->product()); |
|
| 52 | ||
| 53 | Assert::notNull($product, 'Product has not been found'); |
|
| 54 | ||
| 55 | $productVariant = $this->getVariant($putConfigurableItemToCart->options(), $product); |
|
| 56 | ||
| 57 | $this->orderModifier->modify($cart, $productVariant, $putConfigurableItemToCart->quantity()); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * @param array $options |
|
| @@ 42-55 (lines=14) @@ | ||
| 39 | $this->orderModifier = $orderModifier; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function handle(PutVariantBasedConfigurableItemToCart $putConfigurableItemToCart) |
|
| 43 | { |
|
| 44 | /** @var OrderInterface $cart */ |
|
| 45 | $cart = $this->cartRepository->findOneBy(['tokenValue' => $putConfigurableItemToCart->orderToken()]); |
|
| 46 | ||
| 47 | Assert::notNull($cart, 'Cart has not been found'); |
|
| 48 | ||
| 49 | /** @var ProductVariantInterface $productVariant */ |
|
| 50 | $productVariant = $this->productVariantRepository->findOneByCodeAndProductCode($putConfigurableItemToCart->productVariant(), $putConfigurableItemToCart->product()); |
|
| 51 | ||
| 52 | Assert::notNull($productVariant, 'Product variant has not been found'); |
|
| 53 | ||
| 54 | $this->orderModifier->modify($cart, $productVariant, $putConfigurableItemToCart->quantity()); |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||