Inventory Module in Medusa Flows
This document explains how the Inventory Module is used within the Medusa application's flows.
Product Variant Creation
When a product variant is created and its manage_inventory
attribute's value is true
, the Medusa application uses the Inventory Module to create an inventory item associated with that product variant.
Add to Cart
When a product variant with manage_inventory
set to true
is added to cart, the Medusa application uses the Inventory Module to check whether there's sufficient stocked quantity. If not, an error is thrown and the product variant won't be added to the cart.
Order Placed
When an order is placed, the Medusa application uses the Inventory Module to create a reservation item for each product variant with manage_inventory
set to true
. It also sets the reserved_quantity
of the inventory level associated with the inventory item to the ordered quantity of that item.
Order Fulfillment
When an item in an order is fulfilled and the associated variant has its manage_inventory
attribute set to true
, the Medusa application uses the Inventory Module to:
- Subtract the
reserved_quantity
from thestocked_quantity
in the inventory level associated with the variant's inventory item. - Reset the
reserved_quantity
to0
. - Delete the associated reservation item.
Order Return
When an item in an order is returned and the associated variant has its manage_inventory
attribute set to true
, the Medusa application uses the Inventor Module to increment the stocked_quantity
of the inventory level associated with the inventory item with the returned quantity.