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 property's value is true, the Medusa application creates an inventory item associated with that product variant.

TipThis flow is implemented within the createProductVariantsWorkflow

A diagram showcasing how the Inventory Module is used in the product variant creation form


Add to Cart#

When a product variant with manage_inventory set to true is added to 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.

TipThis flow is implemented within the addToCartWorkflow

A diagram showcasing how the Inventory Module is used in the add to cart flow


Order Placed#

When an order is placed, the Medusa application creates a reservation item for each product variant with manage_inventory set to true.

TipThis flow is implemented within the completeCartWorkflow

A diagram showcasing how the Inventory Module is used in the order placed flow


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 the stocked_quantity in the inventory level associated with the variant's inventory item.
  • Resets the reserved_quantity to 0.
  • Deletes the associated reservation item.
TipThis flow is implemented within the createOrderFulfillmentWorkflow

A diagram showcasing how the Inventory Module is used in the order fulfillment flow


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.

TipThis flow is implemented within the confirmReturnReceiveWorkflow

A diagram showcasing how the Inventory Module is used in the order return flow

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.

Was this page helpful?
Edit this page
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break