bagisto/bagisto · error · InsufficientProductInventoryException

shop::app.products.booking.cart.integrity.event.ticket_sold_

Error message

shop::app.products.booking.cart.integrity.event.ticket_sold_out

What it means

Webkul\Product\Exceptions\InsufficientProductInventoryException with the sold-out message from Booking::prepareForCart(), event branch. When isSlotAvailable() fails for a cart line and the Event helper's getAvailableTicketQuantity() returns 0, the code takes the 'ticket_sold_out' variant with the :ticket placeholder, telling the customer that the named ticket tier has no units left at all.

Source

Thrown at packages/Webkul/Product/src/Type/Booking.php:294

                        continue;
                    }

                    $ticket = $bookingProduct->event_tickets()->find($product['additional']['booking']['ticket_id']);

                    $ticketName = $ticket?->name ?? '';

                    $available = $typeHelper->getAvailableTicketQuantity($product);

                    $message = $available > 0
                        ? trans('shop::app.products.booking.cart.integrity.event.ticket_exceeds_available', [
                            'ticket' => $ticketName,
                            'qty' => $available,
                        ])
                        : trans('shop::app.products.booking.cart.integrity.event.ticket_sold_out', [
                            'ticket' => $ticketName,
                        ]);

                    throw new InsufficientProductInventoryException($message);
                }
            }

            $messageKey = match ($bookingProduct->type) {
                'rental' => 'shop::app.products.booking.cart.integrity.rental_unavailable',
                default => 'shop::app.products.booking.cart.integrity.inventory_warning',
            };

            throw new InsufficientProductInventoryException(trans($messageKey));
        }

        $products = $typeHelper->addAdditionalPrices($products);

        return $products;
    }

    /**
     * Compare the booking options of two cart items to determine if they represent the same booking slot/ticket

View on GitHub (pinned to 326bc45f17)

Solutions

  1. Choose a different ticket tier that still has availability, or remove the sold-out line from the cart
  2. Refresh the event page to see current per-tier availability
  3. Raise the tier's qty cap or add a new tier in the booking product admin
  4. Catch InsufficientProductInventoryException and display getMessage() so the customer learns which tier sold out

Example fix

// before
$cartProducts = $product->getTypeInstance()->prepareForCart($data);

// after
try {
    $cartProducts = $product->getTypeInstance()->prepareForCart($data);
} catch (\Webkul\Product\Exceptions\InsufficientProductInventoryException $e) {
    return back()->withErrors($e->getMessage()); // "General ticket is sold out"
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check tier availability before add-to-cart
$typeHelper = app(\Webkul\BookingProduct\Helpers\Event::class);
$available = $typeHelper->getAvailableTicketQuantity($product);

if ($available <= 0) {
    return back()->withErrors('This ticket tier is sold out.');
}

Try / catch

try {
    $cartProducts = $product->getTypeInstance()->prepareForCart($data);
} catch (\Webkul\Product\Exceptions\InsufficientProductInventoryException $e) {
    return back()->withErrors($e->getMessage()); // '<ticket> is sold out'
}

Prevention

When it happens

Trigger: Add-to-cart on an event booking where the requested ticket tier's remaining quantity is exactly 0 (cap fully sold) - e.g. adding a 'General' ticket after the last one was ordered moments ago, while other tiers may still have stock.

Common situations: Ticket tier exhausted between page load and add-to-cart (race at the last unit); admin test orders consuming the full cap; customer re-submitting an old form for a tier that sold out; leftover carts holding the final units at checkout.

Related errors


AI-assisted analysis of bagisto/bagisto@326bc45f17 (2026-08-17). Data as JSON: /api/errors/aa2f82dd8e0f1487. Report an issue: GitHub.