From 82460d647b7557e8618f5b43ea8f0a4dd4636a26 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 11 Oct 2024 10:47:26 +0200 Subject: [PATCH 1/4] [TASK] Refactor EventListener to use doctrine repositories --- .../Product/BeVariantRepository.php | 39 ++++++- .../Product/ProductRepository.php | 39 ++++++- .../CheckProductAvailability.php | 108 ++++++++++-------- .../EventListener/Order/Stock/CheckStock.php | 4 +- .../EventListener/Order/Stock/HandleStock.php | 74 ++++-------- 5 files changed, 152 insertions(+), 112 deletions(-) diff --git a/Classes/Domain/DoctrineRepository/Product/BeVariantRepository.php b/Classes/Domain/DoctrineRepository/Product/BeVariantRepository.php index e5b0caf1..97379c97 100644 --- a/Classes/Domain/DoctrineRepository/Product/BeVariantRepository.php +++ b/Classes/Domain/DoctrineRepository/Product/BeVariantRepository.php @@ -10,6 +10,7 @@ */ use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Database\Query\QueryBuilder; class BeVariantRepository { @@ -19,16 +20,44 @@ public function __construct( public function getStock(int $uid): int { - $queryBuilder = $this - ->connectionPool - ->getConnectionForTable('tx_cartproducts_domain_model_product_bevariant') - ->createQueryBuilder(); + $queryBuilder = $this->getQueryBuilder(); return $queryBuilder ->select('stock') ->from('tx_cartproducts_domain_model_product_bevariant') ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)) - )->executeQuery()->fetchOne(); + ) + ->orWhere( + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)) + ) + ->executeQuery() + ->fetchOne(); + } + + public function addQuantityToStock(int $uid, int $quantity): void + { + $currentStock = $this->getStock($uid); + + $queryBuilder = $this->getQueryBuilder(); + + $queryBuilder + ->update('tx_cartproducts_domain_model_product_bevariant') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)) + ) + ->orWhere( + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)) + ) + ->set('stock', $currentStock - $quantity) + ->executeStatement(); + } + + private function getQueryBuilder(): QueryBuilder + { + return $this + ->connectionPool + ->getConnectionForTable('tx_cartproducts_domain_model_product_bevariant') + ->createQueryBuilder(); } } diff --git a/Classes/Domain/DoctrineRepository/Product/ProductRepository.php b/Classes/Domain/DoctrineRepository/Product/ProductRepository.php index d21f9112..8ccb2613 100644 --- a/Classes/Domain/DoctrineRepository/Product/ProductRepository.php +++ b/Classes/Domain/DoctrineRepository/Product/ProductRepository.php @@ -10,6 +10,7 @@ */ use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\Database\Query\QueryBuilder; class ProductRepository { @@ -19,16 +20,44 @@ public function __construct( public function getStock(int $uid): int { - $queryBuilder = $this - ->connectionPool - ->getConnectionForTable('tx_cartproducts_domain_model_product_product') - ->createQueryBuilder(); + $queryBuilder = $this->getQueryBuilder(); return $queryBuilder ->select('stock') ->from('tx_cartproducts_domain_model_product_product') ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)) - )->executeQuery()->fetchOne(); + ) + ->orWhere( + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)) + ) + ->executeQuery() + ->fetchOne(); + } + + public function addQuantityToStock(int $uid, int $quantity) + { + $currentStock = $this->getStock($uid); + + $queryBuilder = $this->getQueryBuilder(); + + $queryBuilder + ->update('tx_cartproducts_domain_model_product_product') + ->where( + $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)) + ) + ->orWhere( + $queryBuilder->expr()->eq('l10n_parent', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)) + ) + ->set('stock', $currentStock + $quantity) + ->executeStatement(); + } + + private function getQueryBuilder(): QueryBuilder + { + return $this + ->connectionPool + ->getConnectionForTable('tx_cartproducts_domain_model_product_product') + ->createQueryBuilder(); } } diff --git a/Classes/EventListener/CheckProductAvailability.php b/Classes/EventListener/CheckProductAvailability.php index f8342365..f9686fad 100644 --- a/Classes/EventListener/CheckProductAvailability.php +++ b/Classes/EventListener/CheckProductAvailability.php @@ -10,9 +10,12 @@ * For the full copyright and license information, please read the * LICENSE file that was distributed with this source code. */ + +use Extcode\Cart\Domain\Model\Cart\BeVariant as CartProductBeVariant; +use Extcode\Cart\Domain\Model\Cart\Product as CartProduct; use Extcode\Cart\Event\CheckProductAvailabilityEvent; -use Extcode\CartProducts\Domain\Model\Product\Product; -use Extcode\CartProducts\Domain\Repository\Product\ProductRepository; +use Extcode\CartProducts\Domain\DoctrineRepository\Product\BeVariantRepository; +use Extcode\CartProducts\Domain\DoctrineRepository\Product\ProductRepository; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -20,76 +23,85 @@ class CheckProductAvailability { + private CheckProductAvailabilityEvent $event; + public function __construct( - private readonly ProductRepository $productRepository + private readonly ProductRepository $productRepository, + private readonly BeVariantRepository $beVariantRepository, ) {} public function __invoke(CheckProductAvailabilityEvent $event): void { - $cart = $event->getCart(); + $this->event = $event; $cartProduct = $event->getProduct(); - $quantity = $event->getQuantity(); - - $mode = $event->getMode(); - if ($cartProduct->getProductType() !== 'CartProducts') { + if ($cartProduct->getProductType() !== 'CartProducts' || $cartProduct->isHandleStock() === false) { return; } - $querySettings = $this->productRepository->createQuery()->getQuerySettings(); - $querySettings->setRespectStoragePage(false); - $this->productRepository->setDefaultQuerySettings($querySettings); + if ($cartProduct->isHandleStockInVariants()) { + foreach ($cartProduct->getBeVariants() as $cartProductBeVariant) { + $this->checkStockForBeVariant($cartProductBeVariant, $cartProduct); + } + } else { + $this->checkStockForProduct($cartProduct); + } + } - $product = $this->productRepository->findByIdentifier($cartProduct->getProductId()); + private function checkStockForProduct(CartProduct $cartProduct): void + { + $cart = $this->event->getCart(); + $mode = $this->event->getMode(); + + $quantity = $this->event->getQuantity(); + if (is_array($quantity)) { + $compareQuantity = array_sum($quantity); + } else { + $compareQuantity = (int)$quantity; + } - if ( - !$product instanceof Product || - !$product->isHandleStock() - ) { - return; + if (($mode === 'add') && $cart->getProductById($cartProduct->getId())) { + $compareQuantity += $cart->getProductById($cartProduct->getId())->getQuantity(); } - if (!$product->isHandleStockInVariants()) { - if (is_array($quantity)) { - $compareQuantity = array_sum($quantity); - } else { - $compareQuantity = $quantity; - } - if (($mode === 'add') && $cart->getProductById($cartProduct->getId())) { - $compareQuantity += $cart->getProductById($cartProduct->getId())->getQuantity(); - } + $currentStock = $this->productRepository->getStock($cartProduct->getProductId()); - if ($compareQuantity > $product->getStock()) { - $this->falseAvailability($event); - } + if ($compareQuantity > $currentStock) { + $this->falseAvailability(); + } + } - return; + public function checkStockForBeVariant(CartProductBeVariant $cartProductBeVariant, CartProduct $cartProduct): void + { + $cart = $this->event->getCart(); + $mode = $this->event->getMode(); + + $quantity = $this->event->getQuantity(); + if (is_array($quantity)) { + $compareQuantity = array_sum($quantity); + } else { + $compareQuantity = (int)$quantity; } - $compareQuantity = (int)$quantity; + if ( + $mode === 'add' && + $cart->getProductById($cartProduct->getId()) && + $cart->getProductById($cartProduct->getId())->getBeVariantById($cartProductBeVariant->getId()) + ) { + $compareQuantity += $cart->getProductById($cartProduct->getId())->getBeVariantById($cartProductBeVariant->getId())->getQuantity(); + } - foreach ($cartProduct->getBeVariants() as $beVariant) { - if ( - $mode === 'add' && - $cart->getProductById($cartProduct->getId()) && - $cart->getProductById($cartProduct->getId())->getBeVariantById($beVariant->getId()) - ) { - $compareQuantity += (int)$cart->getProductById($cartProduct->getId())->getBeVariantById($beVariant->getId())->getQuantity(); - } + $currentStock = $this->beVariantRepository->getStock((int)$cartProductBeVariant->getId()); - if ($compareQuantity > $beVariant->getStock()) { - $this->falseAvailability($event); - } + if ($compareQuantity > $currentStock) { + $this->falseAvailability(); } } - /** - * @param CheckProductAvailabilityEvent $event - */ - protected function falseAvailability(CheckProductAvailabilityEvent $event): void + private function falseAvailability(): void { - $event->setAvailable(false); - $event->addMessage( + $this->event->setAvailable(false); + $this->event->addMessage( GeneralUtility::makeInstance( FlashMessage::class, LocalizationUtility::translate( diff --git a/Classes/EventListener/Order/Stock/CheckStock.php b/Classes/EventListener/Order/Stock/CheckStock.php index a6ffe706..1dddc452 100644 --- a/Classes/EventListener/Order/Stock/CheckStock.php +++ b/Classes/EventListener/Order/Stock/CheckStock.php @@ -43,7 +43,7 @@ public function __invoke(ProcessOrderCheckStockEvent $event): void if ($cartProduct->isHandleStockInVariants()) { foreach ($cartProduct->getBeVariants() as $cartProductBeVariant) { - $this->checkStockForBackendVariant($cartProductBeVariant, $cartProduct); + $this->checkStockForBeVariant($cartProductBeVariant, $cartProduct); } } else { $this->checkStockForProduct($cartProduct); @@ -60,7 +60,7 @@ private function checkStockForProduct(CartProduct $cartProduct): void } } - public function checkStockForBackendVariant(CartProductBeVariant $cartProductBeVariant, CartProduct $cartProduct): void + public function checkStockForBeVariant(CartProductBeVariant $cartProductBeVariant, CartProduct $cartProduct): void { $quantityInStock = $this->beVariantRepository->getStock((int)$cartProductBeVariant->getId()); diff --git a/Classes/EventListener/Order/Stock/HandleStock.php b/Classes/EventListener/Order/Stock/HandleStock.php index bbce1a24..b1080900 100644 --- a/Classes/EventListener/Order/Stock/HandleStock.php +++ b/Classes/EventListener/Order/Stock/HandleStock.php @@ -11,77 +11,47 @@ * LICENSE file that was distributed with this source code. */ +use Extcode\Cart\Domain\Model\Cart\BeVariant as CartProductBeVariant; use Extcode\Cart\Domain\Model\Cart\Product as CartProduct; use Extcode\Cart\Event\Order\EventInterface; -use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Utility\GeneralUtility; +use Extcode\CartProducts\Domain\DoctrineRepository\Product\BeVariantRepository; +use Extcode\CartProducts\Domain\DoctrineRepository\Product\ProductRepository; class HandleStock { + public function __construct( + private readonly ProductRepository $productRepository, + private readonly BeVariantRepository $beVariantRepository, + ) {} + public function __invoke(EventInterface $event): void { $cartProducts = $event->getCart()->getProducts(); foreach ($cartProducts as $cartProduct) { - if ($cartProduct->getProductType() === 'CartProducts') { - $productConnection = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable('tx_cartproducts_domain_model_product_product'); - $productQueryBuilder = $productConnection->createQueryBuilder(); - - $product = $productQueryBuilder - ->select('uid', 'handle_stock', 'handle_stock_in_variants') - ->from('tx_cartproducts_domain_model_product_product')->where($productQueryBuilder->expr()->eq('uid', $productQueryBuilder->createNamedParameter($cartProduct->getProductId(), \PDO::PARAM_INT)))->executeQuery()->fetchAssociative(); + if ($cartProduct->getProductType() !== 'CartProducts' || $cartProduct->isHandleStock() === false) { + continue; + } - if ($product['handle_stock']) { - if ($product['handle_stock_in_variants']) { - $this->handleStockInBeVariant($cartProduct); - } else { - $this->handleStockInProduct($cartProduct); - } + if ($cartProduct->isHandleStockInVariants()) { + foreach ($cartProduct->getBeVariants() as $cartProductBeVariant) { + $this->handleStockInBeVariant($cartProductBeVariant); } + } else { + $this->handleStockInProduct($cartProduct); } } } - protected function handleStockInProduct(CartProduct $cartProduct): void + private function handleStockInProduct(CartProduct $cartProduct): void { - $productConnection = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable('tx_cartproducts_domain_model_product_product'); - $productQueryBuilder = $productConnection->createQueryBuilder(); - - $product = $productQueryBuilder - ->select('stock') - ->from('tx_cartproducts_domain_model_product_product')->where($productQueryBuilder->expr()->eq('uid', $productQueryBuilder->createNamedParameter($cartProduct->getProductId(), \PDO::PARAM_INT)))->executeQuery()->fetchAssociative(); - - $productQueryBuilder - ->update('tx_cartproducts_domain_model_product_product') - ->where( - $productQueryBuilder->expr()->eq('uid', $productQueryBuilder->createNamedParameter($cartProduct->getProductId(), \PDO::PARAM_INT)) - ) - ->orWhere( - $productQueryBuilder->expr()->eq('l10n_parent', $productQueryBuilder->createNamedParameter($cartProduct->getProductId(), \PDO::PARAM_INT)) - )->set('stock', $product['stock'] - $cartProduct->getQuantity())->executeStatement(); + $quantityToAdd = -1 * ($cartProduct->getQuantity()); + $this->productRepository->addQuantityToStock($cartProduct->getProductId(), $quantityToAdd); } - protected function handleStockInBeVariant(CartProduct $cartProduct): void + private function handleStockInBeVariant(CartProductBeVariant $cartProductBeVariant): void { - $beVariantConnection = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable('tx_cartproducts_domain_model_product_bevariant'); - - foreach ($cartProduct->getBeVariants() as $cartBeVariant) { - $beVariantQueryBuilder = $beVariantConnection->createQueryBuilder(); - $beVariant = $beVariantQueryBuilder - ->select('stock') - ->from('tx_cartproducts_domain_model_product_bevariant')->where($beVariantQueryBuilder->expr()->eq('uid', $beVariantQueryBuilder->createNamedParameter($cartBeVariant->getId(), \PDO::PARAM_INT)))->executeQuery()->fetchAssociative(); - - $beVariantQueryBuilder - ->update('tx_cartproducts_domain_model_product_bevariant') - ->where( - $beVariantQueryBuilder->expr()->eq('uid', $beVariantQueryBuilder->createNamedParameter($cartBeVariant->getId(), \PDO::PARAM_INT)) - ) - ->orWhere( - $beVariantQueryBuilder->expr()->eq('l10n_parent', $beVariantQueryBuilder->createNamedParameter($cartBeVariant->getId(), \PDO::PARAM_INT)) - )->set('stock', $beVariant['stock'] - $cartBeVariant->getQuantity())->executeStatement(); - } + $quantityToAdd = -1 * ($cartProductBeVariant->getQuantity()); + $this->beVariantRepository->addQuantityToStock((int)$cartProductBeVariant->getId(), $quantityToAdd); } } From 87d04694aef55f90912b917f6d4db0ea50b4f9d9 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 11 Oct 2024 12:03:42 +0200 Subject: [PATCH 2/4] [BUGFIX] Check quantity for desired backend variant and stock handling in variants Relates: #217 --- .../CheckProductAvailability.php | 29 ++++++++++++------- .../EventListener/Order/Stock/HandleStock.php | 4 +-- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Classes/EventListener/CheckProductAvailability.php b/Classes/EventListener/CheckProductAvailability.php index f9686fad..7b73e67f 100644 --- a/Classes/EventListener/CheckProductAvailability.php +++ b/Classes/EventListener/CheckProductAvailability.php @@ -54,19 +54,24 @@ private function checkStockForProduct(CartProduct $cartProduct): void $mode = $this->event->getMode(); $quantity = $this->event->getQuantity(); + // $quantity is an array in the event that the number of products with variants is updated in the shopping cart. + // In this case, the number from the update request must be added up, as stock management for all variants + // together takes place in the product. + // $quantity is not an array if a product or a product variant is added via the product page. In this case, the + // value for the quantity must be taken directly. if (is_array($quantity)) { - $compareQuantity = array_sum($quantity); + $quantityInCart = array_sum($quantity); } else { - $compareQuantity = (int)$quantity; + $quantityInCart = (int)$quantity; } if (($mode === 'add') && $cart->getProductById($cartProduct->getId())) { - $compareQuantity += $cart->getProductById($cartProduct->getId())->getQuantity(); + $quantityInCart += $cart->getProductById($cartProduct->getId())->getQuantity(); } - $currentStock = $this->productRepository->getStock($cartProduct->getProductId()); + $quantityInStock = $this->productRepository->getStock($cartProduct->getProductId()); - if ($compareQuantity > $currentStock) { + if ($quantityInStock < $quantityInCart) { $this->falseAvailability(); } } @@ -77,10 +82,14 @@ public function checkStockForBeVariant(CartProductBeVariant $cartProductBeVarian $mode = $this->event->getMode(); $quantity = $this->event->getQuantity(); + // $quantity is an array in the event that the number of products with variants is updated in the shopping cart. + // In this case, the correct quantity from the update request must be used. + // $quantity is not an array if a variant is added via the product page. In this case, the value for the + // quantity must be taken directly. if (is_array($quantity)) { - $compareQuantity = array_sum($quantity); + $quantityInCart = (int)$quantity[$cartProductBeVariant->getId()]; } else { - $compareQuantity = (int)$quantity; + $quantityInCart = (int)$quantity; } if ( @@ -88,12 +97,12 @@ public function checkStockForBeVariant(CartProductBeVariant $cartProductBeVarian $cart->getProductById($cartProduct->getId()) && $cart->getProductById($cartProduct->getId())->getBeVariantById($cartProductBeVariant->getId()) ) { - $compareQuantity += $cart->getProductById($cartProduct->getId())->getBeVariantById($cartProductBeVariant->getId())->getQuantity(); + $quantityInCart += $cart->getProductById($cartProduct->getId())->getBeVariantById($cartProductBeVariant->getId())->getQuantity(); } - $currentStock = $this->beVariantRepository->getStock((int)$cartProductBeVariant->getId()); + $quantityInStock = $this->beVariantRepository->getStock((int)$cartProductBeVariant->getId()); - if ($compareQuantity > $currentStock) { + if ($quantityInStock < $quantityInCart) { $this->falseAvailability(); } } diff --git a/Classes/EventListener/Order/Stock/HandleStock.php b/Classes/EventListener/Order/Stock/HandleStock.php index b1080900..34dd71f8 100644 --- a/Classes/EventListener/Order/Stock/HandleStock.php +++ b/Classes/EventListener/Order/Stock/HandleStock.php @@ -45,13 +45,13 @@ public function __invoke(EventInterface $event): void private function handleStockInProduct(CartProduct $cartProduct): void { - $quantityToAdd = -1 * ($cartProduct->getQuantity()); + $quantityToAdd = -1 * $cartProduct->getQuantity(); $this->productRepository->addQuantityToStock($cartProduct->getProductId(), $quantityToAdd); } private function handleStockInBeVariant(CartProductBeVariant $cartProductBeVariant): void { - $quantityToAdd = -1 * ($cartProductBeVariant->getQuantity()); + $quantityToAdd = -1 * $cartProductBeVariant->getQuantity(); $this->beVariantRepository->addQuantityToStock((int)$cartProductBeVariant->getId(), $quantityToAdd); } } From 99071322d258e22fd82707412b7637174da770ed Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 11 Oct 2024 14:55:40 +0200 Subject: [PATCH 3/4] [TASK] Make method name in EventListener more clear --- .../DoctrineRepository/Product/BeVariantRepository.php | 6 ++++++ .../Domain/DoctrineRepository/Product/ProductRepository.php | 6 ++++++ Classes/EventListener/Order/Stock/HandleStock.php | 6 ++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Classes/Domain/DoctrineRepository/Product/BeVariantRepository.php b/Classes/Domain/DoctrineRepository/Product/BeVariantRepository.php index 97379c97..5ccf9f8c 100644 --- a/Classes/Domain/DoctrineRepository/Product/BeVariantRepository.php +++ b/Classes/Domain/DoctrineRepository/Product/BeVariantRepository.php @@ -53,6 +53,12 @@ public function addQuantityToStock(int $uid, int $quantity): void ->executeStatement(); } + public function subtractQuantityFromStock(int $uid, int $quantity): void + { + $quantity = -1 * $quantity; + $this->addQuantityToStock($uid, $quantity); + } + private function getQueryBuilder(): QueryBuilder { return $this diff --git a/Classes/Domain/DoctrineRepository/Product/ProductRepository.php b/Classes/Domain/DoctrineRepository/Product/ProductRepository.php index 8ccb2613..c0660783 100644 --- a/Classes/Domain/DoctrineRepository/Product/ProductRepository.php +++ b/Classes/Domain/DoctrineRepository/Product/ProductRepository.php @@ -53,6 +53,12 @@ public function addQuantityToStock(int $uid, int $quantity) ->executeStatement(); } + public function subtractQuantityFromStock(int $uid, int $quantity): void + { + $quantity = -1 * $quantity; + $this->addQuantityToStock($uid, $quantity); + } + private function getQueryBuilder(): QueryBuilder { return $this diff --git a/Classes/EventListener/Order/Stock/HandleStock.php b/Classes/EventListener/Order/Stock/HandleStock.php index 34dd71f8..e7dcd328 100644 --- a/Classes/EventListener/Order/Stock/HandleStock.php +++ b/Classes/EventListener/Order/Stock/HandleStock.php @@ -45,13 +45,11 @@ public function __invoke(EventInterface $event): void private function handleStockInProduct(CartProduct $cartProduct): void { - $quantityToAdd = -1 * $cartProduct->getQuantity(); - $this->productRepository->addQuantityToStock($cartProduct->getProductId(), $quantityToAdd); + $this->productRepository->subtractQuantityFromStock($cartProduct->getProductId(), $cartProduct->getQuantity()); } private function handleStockInBeVariant(CartProductBeVariant $cartProductBeVariant): void { - $quantityToAdd = -1 * $cartProductBeVariant->getQuantity(); - $this->beVariantRepository->addQuantityToStock((int)$cartProductBeVariant->getId(), $quantityToAdd); + $this->beVariantRepository->subtractQuantityFromStock((int)$cartProductBeVariant->getId(), $cartProductBeVariant->getQuantity()); } } From b6057911d9a39929fe22120908466944a17cc12f Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 11 Oct 2024 15:04:28 +0200 Subject: [PATCH 4/4] [BUGFIX] Change comment wording --- Classes/EventListener/CheckProductAvailability.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Classes/EventListener/CheckProductAvailability.php b/Classes/EventListener/CheckProductAvailability.php index 7b73e67f..0da263a5 100644 --- a/Classes/EventListener/CheckProductAvailability.php +++ b/Classes/EventListener/CheckProductAvailability.php @@ -54,8 +54,8 @@ private function checkStockForProduct(CartProduct $cartProduct): void $mode = $this->event->getMode(); $quantity = $this->event->getQuantity(); - // $quantity is an array in the event that the number of products with variants is updated in the shopping cart. - // In this case, the number from the update request must be added up, as stock management for all variants + // $quantity is an array in the case that the amount of a product with variants is updated within the shopping + // cart. In this case, the number from the update request must be added up, as stock management for all variants // together takes place in the product. // $quantity is not an array if a product or a product variant is added via the product page. In this case, the // value for the quantity must be taken directly. @@ -82,8 +82,8 @@ public function checkStockForBeVariant(CartProductBeVariant $cartProductBeVarian $mode = $this->event->getMode(); $quantity = $this->event->getQuantity(); - // $quantity is an array in the event that the number of products with variants is updated in the shopping cart. - // In this case, the correct quantity from the update request must be used. + // $quantity is an array in the case that the amount of a product with variants is updated within the shopping + // cart. In this case, the correct quantity from the update request must be used. // $quantity is not an array if a variant is added via the product page. In this case, the value for the // quantity must be taken directly. if (is_array($quantity)) {