---
products:
- cart
- order
---
import { CodeTabs, CodeTab, Table } from "docs-ui"
export const metadata = {
title: `Links between Promotion Module and Other Modules`,
}
# {metadata.title}
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:
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](/references/cart/models/Cart) in [Cart Module](../../cart/page.mdx)
[Promotion](/references/promotion/models/Promotion)
Stored - many-to-many
[Learn more](#cart-module)
[LineItemAdjustment](/references/cart/models/LineItemAdjustment) in [Cart Module](../../cart/page.mdx)
[Promotion](/references/promotion/models/Promotion)
Read-only - has one
[Learn more](#cart-module)
[Order](/references/order/models/Order) in [Order Module](../../order/page.mdx)
[Promotion](/references/promotion/models/Promotion)
Stored - many-to-many
[Learn more](#order-module)
---
## 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.

Medusa also defines a read-only link between the [Cart Module](../../cart/page.mdx)'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](!docs!/learn/fundamentals/module-links/query), pass `carts.*` in `fields`:
To retrieve the promotion of a line item adjustment, pass `promotion.*` in `fields`.
```ts
const { data: promotions } = await query.graph({
entity: "promotion",
fields: [
"carts.*",
],
})
// promotions[0].carts
```
```ts
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
// ...
const { data: promotions } = useQueryGraphStep({
entity: "promotion",
fields: [
"carts.*",
],
})
// promotions[0].carts
```
### Manage with Link
To manage the promotions of a cart, use [Link](!docs!/learn/fundamentals/module-links/link):
```ts
import { Modules } from "@medusajs/framework/utils"
// ...
await link.create({
[Modules.CART]: {
cart_id: "cart_123",
},
[Modules.PROMOTION]: {
promotion_id: "promo_123",
},
})
```
```ts
import { Modules } from "@medusajs/framework/utils"
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
// ...
createRemoteLinkStep({
[Modules.CART]: {
cart_id: "cart_123",
},
[Modules.PROMOTION]: {
promotion_id: "promo_123",
},
})
```
---
## Order Module
An order is associated with the promotion applied on it. Medusa defines a link between the `Order` and `Promotion` data models.

### Retrieve with Query
To retrieve the orders a promotion is applied on with [Query](!docs!/learn/fundamentals/module-links/query), pass `orders.*` in `fields`:
```ts
const { data: promotions } = await query.graph({
entity: "promotion",
fields: [
"orders.*",
],
})
// promotions[0].orders
```
```ts
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
// ...
const { data: promotions } = useQueryGraphStep({
entity: "promotion",
fields: [
"orders.*",
],
})
// promotions[0].orders
```
### Manage with Link
To manage the promotion of an order, use [Link](!docs!/learn/fundamentals/module-links/link):
```ts
import { Modules } from "@medusajs/framework/utils"
// ...
await link.create({
[Modules.ORDER]: {
order_id: "order_123",
},
[Modules.PROMOTION]: {
promotion_id: "promo_123",
},
})
```
```ts
import { Modules } from "@medusajs/framework/utils"
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
// ...
createRemoteLinkStep({
[Modules.ORDER]: {
order_id: "order_123",
},
[Modules.PROMOTION]: {
promotion_id: "promo_123",
},
})
```