{"record":{"id":"aa2f82dd8e0f1487","repo":"bagisto/bagisto","slug":"shop-app-products-booking-cart-integrity-event-ti-aa2f82","errorCode":null,"errorMessage":"shop::app.products.booking.cart.integrity.event.ticket_sold_out","messagePattern":"shop::app\\.products\\.booking\\.cart\\.integrity\\.event\\.ticket_sold_out","errorType":"exception","errorClass":"InsufficientProductInventoryException","httpStatus":null,"severity":"error","filePath":"packages/Webkul/Product/src/Type/Booking.php","lineNumber":294,"sourceCode":"                        continue;\n                    }\n\n                    $ticket = $bookingProduct->event_tickets()->find($product['additional']['booking']['ticket_id']);\n\n                    $ticketName = $ticket?->name ?? '';\n\n                    $available = $typeHelper->getAvailableTicketQuantity($product);\n\n                    $message = $available > 0\n                        ? trans('shop::app.products.booking.cart.integrity.event.ticket_exceeds_available', [\n                            'ticket' => $ticketName,\n                            'qty' => $available,\n                        ])\n                        : trans('shop::app.products.booking.cart.integrity.event.ticket_sold_out', [\n                            'ticket' => $ticketName,\n                        ]);\n\n                    throw new InsufficientProductInventoryException($message);\n                }\n            }\n\n            $messageKey = match ($bookingProduct->type) {\n                'rental' => 'shop::app.products.booking.cart.integrity.rental_unavailable',\n                default => 'shop::app.products.booking.cart.integrity.inventory_warning',\n            };\n\n            throw new InsufficientProductInventoryException(trans($messageKey));\n        }\n\n        $products = $typeHelper->addAdditionalPrices($products);\n\n        return $products;\n    }\n\n    /**\n     * Compare the booking options of two cart items to determine if they represent the same booking slot/ticket","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/bagisto/bagisto/blob/326bc45f17cd66d2835a934d21c264d3ee12d935/packages/Webkul/Product/src/Type/Booking.php#L276-L312","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Choose a different ticket tier that still has availability, or remove the sold-out line from the cart","Refresh the event page to see current per-tier availability","Raise the tier's qty cap or add a new tier in the booking product admin","Catch InsufficientProductInventoryException and display getMessage() so the customer learns which tier sold out"],"exampleFix":"// before\n$cartProducts = $product->getTypeInstance()->prepareForCart($data);\n\n// after\ntry {\n    $cartProducts = $product->getTypeInstance()->prepareForCart($data);\n} catch (\\Webkul\\Product\\Exceptions\\InsufficientProductInventoryException $e) {\n    return back()->withErrors($e->getMessage()); // \"General ticket is sold out\"\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check tier availability before add-to-cart\n$typeHelper = app(\\Webkul\\BookingProduct\\Helpers\\Event::class);\n$available = $typeHelper->getAvailableTicketQuantity($product);\n\nif ($available <= 0) {\n    return back()->withErrors('This ticket tier is sold out.');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $cartProducts = $product->getTypeInstance()->prepareForCart($data);\n} catch (\\Webkul\\Product\\Exceptions\\InsufficientProductInventoryException $e) {\n    return back()->withErrors($e->getMessage()); // '<ticket> is sold out'\n}","preventionTips":["Mark sold-out tiers as disabled on the product page as soon as qty hits 0","Clean up test/failed orders so they don't consume ticket caps","For multi-tier events, keep fallback messaging that suggests other tiers","Treat a 0-availability read as authoritative only under the same transaction as add-to-cart"],"tags":["bagisto","php","booking","event","tickets","sold-out","inventory"],"backgroundTag":"insufficient-inventory","analyzedSha":"326bc45f17cd66d2835a934d21c264d3ee12d935","analyzedAt":"2026-08-17T00:51:54.202Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}