Links between Order Module and Other Modules

This document showcases the module links defined between the Order Module and other commerce modules.

Summary#

The Order Module has the following links to other modules:

TipRead-only links are used to query data across modules, but the relations aren't stored in a pivot table in the database.

Customer Module#

Medusa defines a read-only link between the Order data model and the Customer Module's Customer data model. This means you can retrieve the details of an order's customer, but you don't manage the links in a pivot table in the database. The customer of an order is determined by the customer_id property of the Order data model.

Retrieve with Query#

To retrieve the customer of an order with Query, pass customer.* in fields:


Cart Module#

The Cart Module provides cart-management features.

Medusa defines a link between the Order and Cart data models. The order is linked to the cart used for the purchased.

A diagram showcasing an example of how data models from the Cart and Order modules are linked

Retrieve with Query#

To retrieve the cart of an order with Query, pass cart.* in fields:

To manage the cart of an order, use Link:


Fulfillment Module#

A fulfillment is created for an orders' items. Medusa defines a link between the Fulfillment and Order data models.

A diagram showcasing an example of how data models from the Fulfillment and Order modules are linked

A fulfillment is also created for a return's items. So, Medusa defines a link between the Fulfillment and Return data models.

A diagram showcasing an example of how data models from the Fulfillment and Order modules are linked

Retrieve with Query#

To retrieve the fulfillments of an order with Query, pass fulfillments.* in fields:

NoteTo retrieve the fulfillments of a return, pass fulfillments.* in fields.

To manage the fulfillments of an order, use Link:


Payment Module#

An order's payment details are stored in a payment collection. This also applies for claims and exchanges.

So, Medusa defines links between the PaymentCollection data model and the Order, OrderClaim, and OrderExchange data models.

A diagram showcasing an example of how data models from the Order and Payment modules are linked

Retrieve with Query#

To retrieve the payment collections of an order, order exchange, or order claim with Query, pass payment_collections.* in fields:

To manage the payment collections of an order, use Link:


Product Module#

Medusa defines read-only links between:

  • the OrderLineItem data model and the Product Module's Product data model. This means you can retrieve the details of a line item's product, but you don't manage the links in a pivot table in the database. The product of a line item is determined by the product_id property of the OrderLineItem data model.
  • the OrderLineItem data model and the Product Module's ProductVariant data model. This means you can retrieve the details of a line item's variant, but you don't manage the links in a pivot table in the database. The variant of a line item is determined by the variant_id property of the OrderLineItem data model.

Retrieve with Query#

To retrieve the variant of a line item with Query, pass variant.* in fields:

NoteTo retrieve the product, pass product.* in fields.

Promotion Module#

An order is associated with the promotion applied on it. Medusa defines a link between the Order and Promotion data models.

A diagram showcasing an example of how data models from the Order and Promotion modules are linked

Retrieve with Query#

To retrieve the promotion applied on an order with Query, pass promotion.* in fields:

To manage the promotion of an order, use Link:


Region Module#

Medusa defines a read-only link between the Order data model and the Region Module's Region data model. This means you can retrieve the details of an order's region, but you don't manage the links in a pivot table in the database. The region of an order is determined by the region_id property of the Order data model.

Retrieve with Query#

To retrieve the region of an order with Query, pass region.* in fields:


Sales Channel Module#

Medusa defines a read-only link between the Order data model and the Sales Channel Module's SalesChannel data model. This means you can retrieve the details of an order's sales channel, but you don't manage the links in a pivot table in the database. The sales channel of an order is determined by the sales_channel_id property of the Order data model.

Retrieve with Query#

To retrieve the sales channel of an order with Query, pass sales_channel.* in fields:

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