Inventory Module in Medusa Flows
In this guide, you'll learn how Medusa uses the Inventory Module in its commerce flows, including product variant creation, adding to cart, order placement, order fulfillment, and order return.
Product Variant Creation#
When a product variant is created and its manage_inventory
property's value is true
and the variant's inventory_items
are set, the Medusa application creates an inventory item associated with that product variant.
Add to Cart#
When a product variant with manage_inventory
set to true
is added to the cart, the Medusa application checks whether there's sufficient stocked quantity. If not, an error is thrown and the product variant won't be added to the cart.
Order is Placed#
When an order is placed, the Medusa application creates a reservation item for each product variant with manage_inventory
set to true
.
Order Fulfillment#
When an item in an order is fulfilled and the associated variant has its manage_inventory
property set to true
, the Medusa application:
- Subtracts the
reserved_quantity
from thestocked_quantity
in the inventory level associated with the variant's inventory item. - Resets the
reserved_quantity
to0
. - Deletes the associated reservation item.
Order Return#
When an item in an order is returned and the associated variant has its manage_inventory
property set to true
, the Medusa application increments the stocked_quantity
of the inventory item's level with the returned quantity.
Dismissed Returned Items#
If a returned item is considered damaged or is dismissed, its quantity doesn't increment the stocked_quantity
of the inventory item's level.