Links between Customer Module and Other Modules

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

Summary#

The Customer 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

Customer

AccountHolder in Payment Module

Stored - many-to-many

Learn more

Cart in Cart Module

Customer

Read-only - has one

Learn more

Order in Order Module

Customer

Read-only - has one

Learn more


Payment Module#

Medusa defines a link between the Customer and AccountHolder data models, allowing payment providers to save payment methods for a customer, if the payment provider supports it.

Note: This link is available starting from Medusa v2.5.0.

Retrieve with Query#

To retrieve the account holder associated with a customer with Query, pass customer.* in fields:

To manage the account holders of a customer, use Link:

Note: A customer can have many account holders, but each account holder belongs to only one customer. If you try to link an account holder that already belongs to another customer, Medusa throws a Cannot create multiple links between 'customer' and 'payment' error. To transfer an account holder to a different customer, remove the existing link first, then create the new one.

Cart Module#

Medusa defines a read-only link between the Cart Module's Cart data model and the Customer data model. Because the link is read-only from the Cart's side, you can only retrieve the customer of a cart, and not the other way around.

Retrieve with Query#

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


Order Module#

Medusa defines a read-only link between the Order Module's Order data model and the Customer data model. Because the link is read-only from the Order's side, you can only retrieve the customer of an order, and not the other way around.

Retrieve with Query#

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

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs 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
⇧↵