diff --git a/app/code/Magento/InventoryShipping/Model/DefaultShippingAlgorithm.php b/app/code/Magento/InventoryShipping/Model/DefaultShippingAlgorithm.php index 78743938d694..3027e902c7f5 100644 --- a/app/code/Magento/InventoryShipping/Model/DefaultShippingAlgorithm.php +++ b/app/code/Magento/InventoryShipping/Model/DefaultShippingAlgorithm.php @@ -133,6 +133,7 @@ public function execute(OrderInterface $order): ShippingAlgorithmResultInterface $itemSku = $orderItem->getSku(); $qtyToDeliver = $orderItem->getQtyOrdered(); + //check if order item is not delivered yet if ($orderItem->isDeleted() || $orderItem->getParentItemId() || $this->isZero($qtyToDeliver)) { continue; } @@ -142,6 +143,7 @@ public function execute(OrderInterface $order): ShippingAlgorithmResultInterface $sourceItemQty = $sourceItem->getQuantity(); $qtyToDeduct = min($sourceItemQty, $qtyToDeliver); + // check if source has some qty of SKU, so it's possible to take them into account if ($this->isZero($sourceItemQty)) { continue; } @@ -158,6 +160,8 @@ public function execute(OrderInterface $order): ShippingAlgorithmResultInterface $qtyToDeliver -= $qtyToDeduct; } + // if we go throw all sources from the stock and there is still some qty to delivery, + // then it doesn't have enough items to delivery if (!$this->isZero($qtyToDeliver)) { $isShippable = false; }