Manage inventory with the Cart

Learn about the relationship between a Cart and the Inventory entity.

Ask about this Page
Copy for LLM
View as Markdown

After completing this page, you should be able to:

  • Understand different Cart inventory modes and how they impact the process of converting a Cart to an Order.

Carts provide flexibility in managing inventory through its Cart-level and Line-item-level InventoryMode settings. This granular control dictates how inventory is tracked and decremented throughout the shopping journey.

InventoryMode options

Choose the mode that matches when you want stock checks or reservations to happen, then apply a line item override only when a specific item needs different behavior from the rest of the Cart.

InventoryModeUse it when
NoneYour application or an external system owns inventory validation and reservation logic.
TrackOnlyYou want to accept demand first and reduce inventory only when the Order is created, even if stock can go negative.
ReserveOnOrderYou want to defer the stock check until order creation, but still block Orders that exceed available inventory.
ReserveOnCart BETAYou need to reserve (scarce) stock as soon as a Line Item enters the Cart.

Important considerations

  • Client-side availability checks: only ReserveOnCart prevents customers from adding more items to a Cart than the available inventory supports. If you use another inventory mode, your application must perform that check before the item is added. You can use either the ProductVariantAvailability object or the Inventory API endpoints and then show appropriate feedback in the storefront.
  • Inventory consistency: when you create an Order from a Cart that uses ReserveOnOrder or TrackOnly, or when you use ReserveOnCart, changes to the availableQuantity and quantityOnStock fields of the related InventoryEntry are eventually consistent and can take up to 10 seconds to appear. Direct API updates to inventory resources remain strongly consistent.
  • Line Item InventoryMode and supplyChannel: the Cart-level InventoryMode acts as the default, but you can override it for individual Line Items. You can also assign a supplyChannel to each Line Item to reflect inventory availability in a specific channel. If you omit the supplyChannel, commercetools uses the general inventory level. This matters because your application decides which InventoryEntry fulfills a given Line Item.
  • Changing inventory mode on existing Line Items: you can change the InventoryMode of an existing Line Item with the Set LineItem InventoryMode update action. When you change a Line Item to ReserveOnCart, the platform creates a reservation if enough stock is available. When you change it from ReserveOnCart to another mode, the reservation is released.
  • Fulfilling from multiple inventory entries: if your fulfillment strategy uses multiple inventory locations for the same SKU, create multiple Line Items for that SKU in the Cart. Assign the appropriate supplyChannel to each Line Item so stock is marked against the correct inventory entries. This approach supports more granular fulfillment decisions, such as marketplace scenarios or split fulfillment for shipping optimization.
By understanding and using InventoryMode and supplyChannel effectively, you can build an inventory management approach that matches your business requirements. For more detail on the inventory modes and reservation behavior, see the Inventory overview and the reservations section.