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

  • None: adding items to the Cart and creating Orders do not impact inventory levels. This mode is suitable for scenarios where inventory management is handled entirely by an external system, such as an Inventory Management Service (IMS), or when you want to implement custom inventory logic within your application.
  • TrackOnly: this mode allows the addition of any quantity of items to a Cart, regardless of available stock. Inventory is reduced (and can go negative) when an Order is placed. Note that the inventory reduction is eventually consistent and may take up to 10 seconds to be reflected in the availableQuantity and quantityOnStock fields. This mode is useful for allowing overselling scenarios, accepting backorders, or when you want to allow customers to order items even if they are temporarily out of stock.
  • ReserveOnOrder: similar to TrackOnly, this mode permits the addition of any quantity to the Cart. However, an Order can only be created if sufficient inventory exists at the time of order placement. Inventory is reduced upon successful order placement, with the reduction becoming visible within 10 seconds. This mode helps prevent overselling by reserving stock for orders.
  • ReserveOnCartBETA: This mode guarantees the availability of Line Items when they are added to a Cart. If a reservation fails or expires then the Line Item is removed. This mode is ideal for reserving popular, limited-stock items without having to perform inventory checks on every Cart update.

Important considerations

  • Client-side availability checks: it's crucial to understand that only the ReserveOnCart inventory mode prevents adding items to the Cart that have exceeded their available inventory. If you are using another inventory mode then your application is responsible for performing these checks beforehand. You can use either the ProductVariantAvailability object or the Inventory API endpoints and provide appropriate feedback to the customer. A proactive approach ensures a smoother user experience during the checkout process by preventing order failures due to insufficient stock.
  • Inventory consistency: when creating an Order from a Cart with ReserveOnOrder or TrackOnly inventory modes, or when using the ReserveOnCart mode, 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: while a default InventoryMode is set at the Cart level, you have the flexibility to override it for individual line items. Additionally, each line item can be associated with a specific supplyChannel to accurately reflect inventory availability within that channel. Omitting the supplyChannel will default to using the general inventory level. This is important because your application is responsible for deciding which InventoryEntry fulfills a given line item. This granularity is essential for effectively managing inventory across multiple sales channels.
  • Changing inventory mode on existing line items: you can dynamically change the InventoryMode of existing Line Items using the Set LineItem InventoryMode update action. When changing a Line Item to ReserveOnCart, a reservation is created for that Line Item if sufficient stock is available. Conversely, changing from ReserveOnCart to another mode releases the reservation. This flexibility allows you to adjust inventory management strategies based on real-time business needs, such as reserving high-demand items only during peak shopping periods.
  • Fulfilling from multiple inventory entries: if your fulfillment strategy involves fulfilling a single SKU from multiple inventory locations (for example: to optimize shipping times, costs, or this is a marketplace scenario), you can achieve this by creating multiple line items for the same SKU within the Cart. Each line item should be associated with the appropriate supplyChannel to mark stock against specific inventory entries. This approach allows for more efficient and accurate order fulfillment by managing inventory reservations at a granular level.
By understanding and effectively utilizing the InventoryMode and supplyChannel settings, you can create a robust and flexible inventory management system within your Composable Commerce application, catering to various business requirements and complexities.