From fdef484415c548ceca9f4025ad6d19c655e82784 Mon Sep 17 00:00:00 2001 From: Rutvik Monpara Date: Thu, 1 Jan 2026 12:28:18 +0530 Subject: [PATCH] Wrong backorder qty issue fixed when same product added multiple times with different custom options --- InventorySales/Model/GetBackorder.php | 12 ++++++++++++ .../BackOrderNotifyCustomerCondition.php | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/InventorySales/Model/GetBackorder.php b/InventorySales/Model/GetBackorder.php index 0573a718801..72376c25e05 100644 --- a/InventorySales/Model/GetBackorder.php +++ b/InventorySales/Model/GetBackorder.php @@ -75,6 +75,13 @@ class GetBackorder */ private $getBackorderQty; + /** + * Product backorder qty's checked + * + * @var array + */ + private $backorderQty = []; + /** * @param ObjectFactory $objectFactory * @param FormatInterface $format @@ -161,6 +168,11 @@ public function execute(int $productId, $itemQty, $qtyToCheck, $scopeId): object } } $backorderQty = $this->getBackorderQty->execute($productSku, (int)$stockId, $qty); + if (isset($this->backorderQty[$productSku])) { + $backorderQty -= $this->backorderQty[$productSku]; + } else { + $this->backorderQty[$productSku] = $backorderQty; + } if ($backorderQty > 0) { $result->setItemBackorders($backorderQty); } diff --git a/InventorySales/Model/IsProductSalableCondition/BackOrderNotifyCustomerCondition.php b/InventorySales/Model/IsProductSalableCondition/BackOrderNotifyCustomerCondition.php index 2c54a36bbf4..a00cb2d61cc 100644 --- a/InventorySales/Model/IsProductSalableCondition/BackOrderNotifyCustomerCondition.php +++ b/InventorySales/Model/IsProductSalableCondition/BackOrderNotifyCustomerCondition.php @@ -45,6 +45,13 @@ class BackOrderNotifyCustomerCondition implements IsProductSalableForRequestedQt */ private $getBackorderQty; + /** + * Product backorder qty's checked + * + * @var array + */ + private $backorderQty = []; + /** * @param GetStockItemConfigurationInterface $getStockItemConfiguration * @param GetStockItemDataInterface $getStockItemData @deprecated @@ -81,6 +88,12 @@ public function execute(string $sku, int $stockId, float $requestedQty): Product ) { $backorderQty = $this->getBackorderQty->execute($sku, $stockId, $requestedQty); + if (isset($this->backorderQty[$sku])) { + $backorderQty -= $this->backorderQty[$sku]; + } else { + $this->backorderQty[$sku] = $backorderQty; + } + if ($backorderQty > 0) { $errors = [ $this->productSalabilityErrorFactory->create([