Skip to content

Commit

Permalink
Merge pull request #58 from zans-laksa/1793-backorders
Browse files Browse the repository at this point in the history
Cart Backorders Items
  • Loading branch information
lianastaskevica authored May 14, 2021
2 parents 78ff538 + 90c9bd4 commit a503d3d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Model/Resolver/SaveCartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,10 @@ protected function checkItemQty(CartItemInterface $cartItem, $qty): void
return;
}

$allowedBackorder = $stockItem->getBackorders();
$fitsInStock = $qty <= $stockItem->getQty();

if (!$fitsInStock) {
if (!$fitsInStock && !$allowedBackorder) {
throw new GraphQlInputException(new Phrase('Provided quantity exceeds stock limits'));
}

Expand Down Expand Up @@ -486,7 +487,7 @@ protected function checkItemQty(CartItemInterface $cartItem, $qty): void

$qtyLeftInStock = $qtyWithReservation - $stockItemConfiguration->getMinQty();

$isInStock = bccomp((string) $qtyLeftInStock, (string) $qty, 4) >= 0;
$isInStock = bccomp((string) $qtyLeftInStock, (string) $qty, 4) >= 0 || $allowedBackorder;
$isEnoughQty = (bool)$stockItemData[GetStockItemDataInterface::IS_SALABLE] && $isInStock;

if (!$isEnoughQty) {
Expand Down

0 comments on commit a503d3d

Please sign in to comment.