CodeExplorer ProductStockReachedError example
$minPurchase =
$quantityInformation->
getMinPurchase();
$available =
$quantityInformation->
getMaxPurchase() ?? 0;
$steps =
$quantityInformation->
getPurchaseSteps() ?? 1;
if ($available >=
$quantity) { continue;
} $maxAvailable =
(int) (floor(($available -
$minPurchase) /
$steps) *
$steps +
$minPurchase);
$cart->
addErrors( new ProductStockReachedError($productId,
(string) $lineItem->
getLabel(),
$maxAvailable, false
),
);
} }}