Links between Cart Module and Other Modules

This document showcases the module links defined between the Cart Module and other Commerce Modules.

Summary#

The Cart Module has the following links to other modules:

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

First Data Model

Second Data Model

Type

Description

Cart

Customer in Customer Module

Read-only - has one

Learn more

ShippingMethod

ShippingOption in Fulfillment Module

Read-only - has one

Learn more

Order in Order Module

Cart

Stored - one-to-one

Learn more

Cart

PaymentCollection in Payment Module

Stored - one-to-one

Learn more

LineItem

Product in Product Module

Read-only - has one

Learn more

LineItem

ProductVariant in Product Module

Read-only - has one

Learn more

Cart

Promotion in Promotion Module

Stored - many-to-many

Learn more

Cart

Region in Region Module

Read-only - has one

Learn more

Cart

SalesChannel in Sales Channel Module

Read-only - has one

Learn more


Customer Module#

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

Retrieve with Query#

To retrieve the customer of a cart with Query, pass customer.* in fields:


Fulfillment Module#

Medusa defines a read-only link between the ShippingMethod data model and the Fulfillment Module's ShippingOption data model. This means you can retrieve the details of a shipping method's shipping option, but you don't manage the links in a pivot table in the database. The shipping option of a shipping method is determined by the shipping_option_id property of the ShippingMethod data model.

This link allows you to retrieve the shipping option that a shipping method was created from.

Note: This read-only link was added in Medusa v2.10.0

Retrieve with Query#

To retrieve the shipping option of a shipping method with Query, pass shipping_option.* in fields:

Order Module#

The Order Module provides order-management features.

Medusa defines a link between the Cart and Order data models. The cart is linked to the order created once the cart is completed.

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

Retrieve with Query#

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

To manage the order of a cart, use Link:


Payment Module#

The Payment Module handles payment processing and management.

Medusa defines a link between the Cart and PaymentCollection data models. A cart has a payment collection which holds all the authorized payment sessions and payments made related to the cart.

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

Retrieve with Query#

To retrieve the payment collection of a cart with Query, pass payment_collection.* in fields:

To manage the payment collection of a cart, use Link:


Product Module#

Medusa defines read-only links between:

  • the LineItem 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 LineItem data model.
  • the LineItem 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 LineItem data model.

Retrieve with Query#

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

Note: To retrieve the product, pass product.* in fields.

Promotion Module#

The Promotion Module provides discount features.

Medusa defines a link between the Cart and Promotion data models. This indicates the promotions applied on a cart.

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

Medusa also defines a read-only link between the LineItemAdjustment and Promotion data models. This means you can retrieve the details of the promotion applied on a line item, but you don't manage the links in a pivot table in the database. The promotion of a line item is determined by the promotion_id property of the LineItemAdjustment data model.

Retrieve with Query#

To retrieve the promotions of a cart with Query, pass promotions.* in fields:

Note: To retrieve the promotion of a line item adjustment, pass promotion.* in fields.

To manage the promotions of a cart, use Link:


Region Module#

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

Retrieve with Query#

To retrieve the region of a cart with Query, pass region.* in fields:


Sales Channel Module#

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

Retrieve with Query#

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

Was this page helpful?
Ask Anything
Ask any questions about Medusa. Get help with your development.
You can also use the Medusa MCP server in Cursor, VSCode, etc...
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