Links between Promotion Module and Other Modules

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

Summary#

The Promotion 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 in Cart Module

Promotion

Stored - many-to-many

Learn more

LineItemAdjustment in Cart Module

Promotion

Read-only - has one

Learn more

Order in Order Module

Promotion

Stored - many-to-many

Learn more


Cart Module#

A promotion can be applied on line items and shipping methods of a cart. Medusa defines a link between the Cart and Promotion data models.

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 Cart Module's LineItemAdjustment data model and the Promotion data model. Because the link is read-only from the LineItemAdjustment's side, you can only retrieve the promotion applied on a line item, and not the other way around.

Retrieve with Query#

To retrieve the carts that a promotion is applied on with Query, pass carts.* 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:


Order 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 orders a promotion is applied on with Query, pass orders.* in fields:

To manage the promotion of an order, use Link:

Was this page helpful?
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