Bagisto Marketplace: “The requested quantity is not available” on add-to-cart (seller flow) despite seller stock visible on channel
-
Symptom
When adding a seller product to cart from PDP, we consistently get:
The requested quantity is not available, please try again later.
packages/Webkul/Marketplace/src/Cart.php:108
The same happens if we call add-to-cart from a small diagnostic route (Product object + seller context).What we have verified
- Product / stock / channel mapping
- product_flat (product_id=54) → price=60, status=1, visible_individually=1, weight=5.
- Seller stock exists (vendor_id = 2) and channel sees source #5:
-- seller-scoped stock in active channel (returns 7)
SELECT SUM(pi.qty) AS salable_qty_seller
FROM product_inventories pi
JOIN channel_inventory_sources cis ON cis.inventory_source_id = pi.inventory_source_id
WHERE pi.product_id = 54
AND pi.vendor_id = 2
AND cis.channel_id = 1; - Raw inventory row:
SELECT * FROM product_inventories
WHERE product_id=54 AND vendor_id=2;
-- → (id=?, qty=7, product_id=54, vendor_id=2, inventory_source_id=5) - Channel “Balkan” inventory sources = 1, 2, 5 (vendor source #5 enabled).
- Seller panel → Settings → Inventory Sources → source #5 Active.
- Marketplace tables
- Marketplace product row exists & approved:
SELECT * FROM marketplace_products WHERE product_id=54;
/* → id=34, product_id=54, marketplace_seller_id=2, is_approved=1, is_owner=1 */
-
Seller payload we submit
We post a complete seller context (product object, not ID):
{
"product_id": 54,
"quantity": 1,
"seller_id": 2,
"marketplace_seller_id": 2,
"seller_product_id": 34,
"inventory_source_id": 5,
"vendor_id": 2
} -
Route & middlewares
We load a small proxy route under shop middlewares:
// app/Providers/MpRouteServiceProvider.php
Route::middleware(['web','channel','theme','locale','currency'])
->group(base_path('routes/mp.php'));
// routes/mp.php (excerpt)
Route::post('/mp-add-to-cart', function (Request $r, ProductRepository $products) {
$p = $products->findOrFail((int) $r->input('product_id')); // Product OBJECT$data = $r->validate([ 'product_id' => 'required|integer', 'quantity' => 'nullable|integer|min:1', 'seller_id' => 'nullable|integer', 'seller_product_id' => 'nullable|integer', 'marketplace_seller_id' => 'nullable|integer', 'inventory_source_id' => 'nullable|integer', 'vendor_id' => 'nullable|integer', ]); $payload = ['quantity' => (int)($data['quantity'] ?? 1)]; foreach (['seller_id','seller_product_id','marketplace_seller_id','inventory_source_id','vendor_id'] as $k) { if (!empty($data[$k])) $payload[$k] = (int) $data[$k]; } \Log::error('MP ADD payload', $payload); // we see it in logs // Marketplace Cart first: try { \Webkul\Checkout\Facades\Cart::addProduct($p, $payload); } catch (\Throwable $e) { // TEMP fallback so checkout doesn’t block (works): if (str_contains($e->getMessage(), 'requested quantity')) { app(\Webkul\Checkout\Cart::class)->addProduct($p, ['quantity' => $payload['quantity']]); } else { throw $e; } } return redirect('/checkout/cart');
});
- PDP seller CTA
On PDP we render seller info and post to /mp-add-to-cart with the payload fields above.
The problem
Even with the complete seller payload (and channel seeing source #5), Marketplace Cart still throws “requested quantity is not available …” from Marketplace/src/Cart.php:108.
If we enable the core fallback in our route, item is added to cart and checkout works; but we’d like to keep the pure Marketplace flow.Question
For this Bagisto Marketplace build, what exact parameter(s) or flag does Marketplace Cart need at addProduct($product, $data) to pick the seller stock in the active channel?
We already include: seller_product_id, marketplace_seller_id, vendor_id, inventory_source_id, and the route runs with web, channel, theme, locale, currency.
Seller stock (vendor_id=2 on source_id=5) is present and visible to the channel (salable_qty_seller = 7).
Is there any additional switch or internal lookup (e.g., a specific field in seller profile) our minor version expects so that the Cart sums the seller stock instead of returning 0?
Any pointer/snippet would be highly appreciated. Thanks a lot!
Notes
We’re currently using the core fallback so store can sell normally; looking to remove it once we align the Marketplace Cart expectations.
Thanks!
-
@Radoje [UPDATE – Oct 8, 2025]
• Environment: PHP 8.2.29 • Laravel 11.44.2 • Marketplace 2.3.0_1 • Bagisto app on Laravel 11 • DB: MariaDB 10.6.23
• Channel (default/Balkan) is mapped to sources 1,2,5; seller-scoped stock in the active channel sums to 7
• Seller payload includes: product_id, quantity, seller_id, marketplace_seller_id, seller_product_id, inventory_source_id, vendor_id
• Route runs under ['web','channel','theme','locale','currency'] and passes a Product OBJECT
• Still getting “requested quantity is not available” from Marketplace/src/Cart.php:108; the cart remains empty in all variants we tried
VersionsPHP: 8.2.29 (Cloudways)
Laravel: 11.44.2
Bagisto app: on Laravel 11
Marketplace module: 2.3.0_1
DB: MariaDB 10.6.23
SQL confirmations
-- Seller stock visible in the active channel (returns 7) SELECT SUM(pi.qty) AS salable_qty_seller FROM product_inventories pi JOIN channel_inventory_sources cis ON cis.inventory_source_id = pi.inventory_source_id WHERE pi.product_id = 54 AND pi.vendor_id = 2 AND cis.channel_id = 1; -- Raw inventory row SELECT * FROM product_inventories WHERE product_id=54 AND vendor_id=2; /* -> (id=45, qty=7, product_id=54, vendor_id=2, inventory_source_id=5) */ -- Marketplace product row (approved/owner) SELECT * FROM marketplace_products WHERE product_id=54; /* -> (id=34, product_id=54, marketplace_seller_id=2, is_approved=1, is_owner=1) */ Route context // app/Providers/MpRouteServiceProvider.php Route::middleware(['web','channel','theme','locale','currency']) ->group(base_path('routes/mp.php')); Seller proxy (POST) — full seller payload // routes/mp.php (excerpt) Route::post('/mp-add-to-cart', function (Request $r, ProductRepository $products) { $p = $products->findOrFail((int) $r->input('product_id')); // Product OBJECT $data = $r->validate([ 'product_id'=>'required|integer','quantity'=>'nullable|integer|min:1', 'seller_id'=>'nullable|integer','seller_product_id'=>'nullable|integer', 'marketplace_seller_id'=>'nullable|integer','inventory_source_id'=>'nullable|integer', 'vendor_id'=>'nullable|integer', ]); $payload = ['quantity'=>(int)($data['quantity']??1)]; foreach (['seller_id','seller_product_id','marketplace_seller_id','inventory_source_id','vendor_id'] as $k) { if (!empty($data[$k])) $payload[$k]=(int)$data[$k]; } \Log::error('MP ADD payload', $payload); \Webkul\Checkout\Facades\Cart::addProduct($p, $payload); // Marketplace Cart return redirect('/checkout/cart'); }); Logged payload (from laravel.log) MP ADD payload {"quantity":1,"seller_id":2,"seller_product_id":34,"marketplace_seller_id":2,"inventory_source_id":5,"vendor_id":2} Behavior Calling the handler above raises: The requested quantity is not available, please try again later. (packages/Webkul/Marketplace/src/Cart.php:108) The cart stays empty (cart_items has no rows) in all variants we tried. Question (recap) What exact parameter/flag does this Marketplace build need at addProduct($product, $data) so that the Cart picks the seller stock (vendor_id=2 on inventory_source_id=5) in the active channel, instead of returning 0? We already submit: seller_product_id, marketplace_seller_id, vendor_id, inventory_source_id; the route runs under web, channel, theme, locale, currency. SQL confirms the seller’s stock in the channel is 7.