bagisto/bagisto · error · InsufficientProductInventoryException
product::app.checkout.cart.inventory-warning
Error message
product::app.checkout.cart.inventory-warning
What it means
Webkul\Product\Exceptions\InsufficientProductInventoryException thrown by the base product type's prepareForCart() (AbstractType). Before building the cart line it normalizes the requested qty (handleQuantity, getQtyRequest) and calls haveSufficientQuantity(qty); when saleable stock (inventory sources on hand minus allocated/reserved quantity) cannot cover the request it throws this translated message. Every product type inherits this gate, so both storefront add-to-cart and API/HEADLESS cart operations funnel through it.
Source
Thrown at packages/Webkul/Product/src/Type/AbstractType.php:817
return core()->getTaxCategoryById($taxCategoryId);
}
/**
* Add product. Returns error message if can't prepare product.
*
* @param array $data
* @return array
*
* @throws InsufficientProductInventoryException
*/
public function prepareForCart($data)
{
$data['quantity'] = $this->handleQuantity((int) $data['quantity']);
$data = $this->getQtyRequest($data);
if (! $this->haveSufficientQuantity($data['quantity'])) {
throw new InsufficientProductInventoryException(trans('product::app.checkout.cart.inventory-warning'));
}
$price = $this->getFinalPrice();
$products = [
[
'product_id' => $this->product->id,
'sku' => $this->product->sku,
'quantity' => $data['quantity'],
'name' => $this->product->name,
'price' => $convertedPrice = core()->convertPrice($price),
'price_incl_tax' => $convertedPrice,
'base_price' => $price,
'base_price_incl_tax' => $price,
'total' => $convertedPrice * $data['quantity'],
'total_incl_tax' => $convertedPrice * $data['quantity'],
'base_total' => $price * $data['quantity'],
'base_total_incl_tax' => $price * $data['quantity'],View on GitHub (pinned to 326bc45f17)
Solutions
- Retry with a quantity within available stock, or raise the product's inventory in Admin > Inventory (per-source qty) and ensure at least one source is assigned
- Enable backorders (globally or per product) so haveSufficientQuantity() passes when intentional
- If the product is intentionally always available, disable stock management for it
- In custom add-to-cart code, catch InsufficientProductInventoryException and surface getMessage() as the cart error
Example fix
// before
$result = $product->getTypeInstance()->prepareForCart($data);
// after - validate stock first, then still guard with the exception
$type = $product->getTypeInstance();
if (! $type->haveSufficientQuantity((int) $data['quantity'])) {
return back()->withErrors(trans('product::app.checkout.cart.inventory-warning'));
}
try {
$result = $type->prepareForCart($data);
} catch (\Webkul\Product\Exceptions\InsufficientProductInventoryException $e) {
return back()->withErrors($e->getMessage());
} Defensive patterns
Strategy: validation
Validate before calling
// Before Cart::addProduct / prepareForCart
$type = $product->getTypeInstance();
if (! $type->haveSufficientQuantity((int) $data['quantity'])) {
return back()->withErrors(trans('product::app.checkout.cart.inventory-warning'));
} Try / catch
try {
$result = $product->getTypeInstance()->prepareForCart($data);
} catch (\Webkul\Product\Exceptions\InsufficientProductInventoryException $e) {
// $e->getMessage() is already locale-translated
session()->flash('error', $e->getMessage());
return redirect()->back();
} Prevention
- Call haveSufficientQuantity() with the exact qty right before add-to-cart
- Show remaining stock on the product page and clamp the qty input to it
- Account for reserved/allocated qty, not just on-hand, when forecasting availability
- Catch InsufficientProductInventoryException separately from generic exceptions in cart flows
When it happens
Trigger: POST add-to-cart (shop CartController::store or REST cart add) with a quantity greater than the product's current saleable qty; or checkout/order re-validation when stock dropped between adding to cart and placing the order.
Common situations: Stock consumed by concurrent orders after the product page was loaded; product has inventory sources assigned but zero on hand (or no source assigned so total qty is 0); pending orders reserving/allocating qty; customer typing a qty larger than allowed without the storefront pre-checking.
Related errors
- product::app.checkout.cart.inventory-warning
- product::app.checkout.cart.inventory-warning
- product::app.checkout.cart.inventory-warning
- shop::app.products.booking.cart.integrity.event.ticket_excee
- shop::app.products.booking.cart.integrity.rental_unavailable
AI-assisted analysis of bagisto/bagisto@326bc45f17 (2026-08-17).
Data as JSON: /api/errors/b8d0056200c80063.
Report an issue: GitHub.