6 declare(strict_types=1);
33 private $objectFactory;
43 private $isProductSalableForRequestedQty;
48 private $getSkusByProductIds;
53 private $stockResolver;
58 private $storeManager;
63 private $backOrderNotifyCustomerCondition;
76 ObjectFactory $objectFactory,
84 $this->objectFactory = $objectFactory;
86 $this->isProductSalableForRequestedQty = $isProductSalableForRequestedQty;
87 $this->getSkusByProductIds = $getSkusByProductIds;
88 $this->stockResolver = $stockResolver;
90 $this->backOrderNotifyCustomerCondition = $backOrderNotifyCustomerCondition;
109 public function aroundCheckQuoteItemQty(
118 $result = $this->objectFactory->create();
121 $qty = $this->getNumber($itemQty);
126 $websiteCode = $this->storeManager->getWebsite()->getCode();
128 $stockId =
$stock->getStockId();
130 $isSalableResult = $this->isProductSalableForRequestedQty->execute($productSku, (
int)$stockId, $qty);
132 if ($isSalableResult->isSalable() ===
false) {
134 foreach ($isSalableResult->getErrors() as $error) {
135 $result->setHasError(
true)->setMessage($error->getMessage())->setQuoteMessage($error->getMessage())
136 ->setQuoteMessageIndex(
'qty');
140 $productSalableResult = $this->backOrderNotifyCustomerCondition->execute($productSku, (
int)$stockId, $qty);
141 if ($productSalableResult->getErrors()) {
143 foreach ($productSalableResult->getErrors() as $error) {
144 $result->setMessage($error->getMessage());
158 private function getNumber($qty)
160 if (!is_numeric($qty)) {
161 return $this->format->getNumber($qty);
foreach($websiteCodes as $websiteCode) $skus
__construct(ObjectFactory $objectFactory, FormatInterface $format, IsProductSalableForRequestedQtyInterface $isProductSalableForRequestedQty, GetSkusByProductIdsInterface $getSkusByProductIds, StockResolverInterface $stockResolver, StoreManagerInterface $storeManager, BackOrderNotifyCustomerCondition $backOrderNotifyCustomerCondition)
if(!isset($_GET['website_code'])) $websiteCode