How to Prevent Shared Bundle Inventory from Overselling Across Sales Channels
A gift set containing two mugs and one box looks like one product to a customer. Your inventory system must still treat it as three physical units. When those mugs also sell individually or inside other bundles, assigning independent stock quantities to every listing can promise the same inventory several times.
The practical solution is component-level availability, transactional reservations, and a clear policy for channels that cannot reserve stock before accepting an order.
Calculate availability from components
Keep a bill of materials for each bundle: component SKU, required quantity, and recipe version. Map every marketplace listing to the same internal product identifiers.
For each component, calculate:
available = max(0, on_hand - reserved - safety_stock)
bundle_capacity = minimum floor(available / required_quantity)
With 12 mugs and seven boxes, a bundle requiring two mugs and one box has capacity six. Reserve four mugs for another order and capacity becomes four. That is four across the shared pool, not four independently available on every marketplace.
Shopify documents the same divide-and-round-down approach to bundle availability. Its inventory-tracking and “continue selling when out of stock” settings also affect which components constrain availability. Check these settings rather than assuming a bundle listing always enforces a stock limit. Shopify bundle inventory documentation
Calculate against stock that can actually fulfill the order. If a bundle must ship together, mugs in one warehouse and boxes in another should not automatically count as a complete set.
Reserve the entire order atomically
A separate “check stock” request followed by “deduct stock” leaves a race: two checkouts can both observe the last available mug.
For a custom PostgreSQL-backed service, use one short transaction:
- Resolve the order into component quantities, combining repeated SKUs across all lines.
- Lock every required inventory row using
SELECT ... FOR UPDATE, in a consistent SKU-and-location order. - Check that every required row exists and has sufficient available stock.
- Increase reserved quantities and record the reservation with a unique channel/order identity.
- Write a pending stock-update event to an outbox table, then commit.
If any component fails, roll back everything. PostgreSQL documents that conflicting updates wait for row locks to be released. Consistent lock ordering reduces deadlock risk, but the application must still handle transaction retries. PostgreSQL locking documentation
Define reservation states explicitly. Shipping reduces both on-hand and reserved quantities; cancellation releases the reservation. Return stock becomes available only after the relevant items are received and accepted back into sellable inventory. This avoids treating a refund as a physical restock.
Treat channel updates as fallible messages
Publish stock changes after the database commit, with retryable delivery from the outbox. Deduplicate incoming notifications and apply order-state transitions idempotently so retries cannot reserve or release stock twice. Shopify explicitly warns that webhook deliveries can repeat. Shopify webhook verification and duplicate handling
A crucial limit remains: database correctness cannot prevent an independent marketplace from accepting an order against an old published quantity. To prevent competing channels from selling the same units, either require synchronous reservation before acceptance or allocate separate quotas that each channel enforces, backed by reserved component stock. Safety buffers reduce exposure but do not provide the same guarantee. Quota changes also need acknowledged updates before reallocating units elsewhere.
Test the failure cases
Test simultaneous orders for the last component, duplicate notifications, delayed cancellations, failed publication, partial returns, and a bundle recipe changed after purchase. Preserve each order’s original component breakdown.
Monitor rejected reservations, synchronization lag, and differences between published and authoritative availability. A stock ledger is useful only when it stays correct under the failures that real sales channels produce.