diff --git a/www/apps/resources/app/commerce-modules/api-key/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/api-key/links-to-other-modules/page.mdx
index 3ef22327a671c..ed4bc382efc22 100644
--- a/www/apps/resources/app/commerce-modules/api-key/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/api-key/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between API Key Module and Other Modules`,
}
@@ -6,6 +8,14 @@ export const metadata = {
This document showcases the module links defined between the API Key Module and other commerce modules.
+## Summary
+
+The API Key Module has the following links to other modules:
+
+- [`ApiKey` data model \<\> `SalesChannel` data model of Sales Channel Module](#sales-channel-module).
+
+---
+
## Sales Channel Module
You can create a publishable API key and associate it with a sales channel. Medusa defines a link between the `ApiKey` and the `SalesChannel` data models.
@@ -15,3 +25,86 @@ You can create a publishable API key and associate it with a sales channel. Medu
This is useful to avoid passing the sales channel's ID as a parameter of every request, and instead pass the publishable API key in the header of any request to the Store API route.
Learn more about this in the [Sales Channel Module's documentation](../../sales-channel/publishable-api-keys/page.mdx).
+
+### Retrieve with Query
+
+To retrieve the sales channels of an API key with [Query](!docs!/learn/fundamentals/module-links/query), pass `sales_channels.*` in `fields`:
+
+
+
+
+```ts
+const { data: apiKeys } = await query.graph({
+ entity: "api_key",
+ fields: [
+ "sales_channels.*"
+ ]
+})
+
+// apiKeys.sales_channels
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: apiKeys } = useQueryGraphStep({
+ entity: "api_key",
+ fields: [
+ "sales_channels.*"
+ ]
+})
+
+// apiKeys.sales_channels
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the sales channels of an API key, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.API_KEY]: {
+ api_key_id: "apk_123",
+ },
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.API_KEY]: {
+ api_key_id: "apk_123",
+ },
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+})
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/cart/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/cart/links-to-other-modules/page.mdx
index b6cf0c2054f7d..341ec6d153eb9 100644
--- a/www/apps/resources/app/commerce-modules/cart/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/cart/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Cart Module and Other Modules`,
}
@@ -6,30 +8,496 @@ export const metadata = {
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:
+
+
+
+Read-only links are used to query data across modules, but the relations aren't stored in a pivot table in the database.
+
+
+
+- [`Cart` data model \<\> `Customer` data model of Customer Module](#customer-module). (Read-only).
+- [`Order` data model of Order Module \<\> `Cart` data model](#order-module).
+- [`Cart` data model \<\> `PaymentCollection` data model of Payment Module](#payment-module).
+- [`LineItem` data model \<\> `Product` data model of Product Module](#product-module). (Read-only).
+- [`LineItem` data model \<\> `ProductVariant` data model of Product Module](#product-module). (Read-only).
+- [`Cart` data model \<\> `Promotion` data model of Promotion Module](#promotion-module).
+- [`Cart` data model \<\> `Region` data model of Region Module](#region-module). (Read-only).
+- [`Cart` data model \<\> `SalesChannel` data model of Sales Channel Module](#sales-channel-module). (Read-only).
+
+---
+
+## Customer Module
+
+Medusa defines a read-only link between the `Cart` data model and the [Customer Module](../../customer/page.mdx)'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](!docs!/learn/fundamentals/module-links/query), pass `customer.*` in `fields`:
+
+
+
+
+```ts
+const { data: carts } = await query.graph({
+ entity: "cart",
+ fields: [
+ "customer.*"
+ ]
+})
+
+// carts.order
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: carts } = useQueryGraphStep({
+ entity: "cart",
+ fields: [
+ "customer.*"
+ ]
+})
+
+// carts.order
+```
+
+
+
+
+---
+
+## Order Module
+
+The [Order Module](../../order/page.mdx) 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](https://res.cloudinary.com/dza7lstvk/image/upload/v1728375735/Medusa%20Resources/cart-order_ijwmfs.jpg)
+
+### Retrieve with Query
+
+To retrieve the order of a cart with [Query](!docs!/learn/fundamentals/module-links/query), pass `order.*` in `fields`:
+
+
+
+
+```ts
+const { data: carts } = await query.graph({
+ entity: "cart",
+ fields: [
+ "order.*"
+ ]
+})
+
+// carts.order
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: carts } = useQueryGraphStep({
+ entity: "cart",
+ fields: [
+ "order.*"
+ ]
+})
+
+// carts.order
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the order of a cart, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.CART]: {
+ cart_id: "cart_123",
+ },
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.CART]: {
+ cart_id: "cart_123",
+ },
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+})
+```
+
+
+
+
+---
+
## Payment Module
-The Payment Module handles payment processing and management.
+The [Payment Module](../../payment/page.mdx) 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](https://res.cloudinary.com/dza7lstvk/image/upload/v1711537849/Medusa%20Resources/cart-payment_ixziqm.jpg)
+### Retrieve with Query
+
+To retrieve the payment collection of a cart with [Query](!docs!/learn/fundamentals/module-links/query), pass `payment_collection.*` in `fields`:
+
+
+
+
+```ts
+const { data: carts } = await query.graph({
+ entity: "cart",
+ fields: [
+ "payment_collection.*"
+ ]
+})
+
+// carts.payment_collection
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: carts } = useQueryGraphStep({
+ entity: "cart",
+ fields: [
+ "payment_collection.*"
+ ]
+})
+
+// carts.payment_collection
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the payment collection of a cart, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.CART]: {
+ cart_id: "cart_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_collection_id: "paycol_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.CART]: {
+ cart_id: "cart_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_collection_id: "paycol_123",
+ },
+})
+```
+
+
+
+
+---
+
+## Product Module
+
+Medusa defines read-only links between:
+
+- the `LineItem` data model and the [Product Module](../../product/page.mdx)'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](../../product/page.mdx)'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](!docs!/learn/fundamentals/module-links/query), pass `variant.*` in `fields`:
+
+
+
+To retrieve the product, pass `product.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: lineItems } = await query.graph({
+ entity: "line_item",
+ fields: [
+ "variant.*"
+ ]
+})
+
+// lineItems.variant
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: lineItems } = useQueryGraphStep({
+ entity: "line_item",
+ fields: [
+ "variant.*"
+ ]
+})
+
+// lineItems.variant
+```
+
+
+
+
---
## Promotion Module
-The Promotion Module provides discount features.
+The [Promotion Module](../../promotion/page.mdx) 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](https://res.cloudinary.com/dza7lstvk/image/upload/v1711538015/Medusa%20Resources/cart-promotion_kuh9vm.jpg)
+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](!docs!/learn/fundamentals/module-links/query), pass `promotions.*` in `fields`:
+
+
+
+To retrieve the promotion of a line item adjustment, pass `promotion.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: carts } = await query.graph({
+ entity: "cart",
+ fields: [
+ "promotions.*"
+ ]
+})
+
+// carts.promotions
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: carts } = useQueryGraphStep({
+ entity: "cart",
+ fields: [
+ "promotions.*"
+ ]
+})
+
+// carts.promotions
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the promotions of a cart, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.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
+## Region Module
-The Order Module provides order-management features.
+Medusa defines a read-only link between the `Cart` data model and the [Region Module](../../region/page.mdx)'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.
-Medusa defines a link between the `Cart` and `Order` data models. The cart is linked to the order created once the cart is completed.
+### Retrieve with Query
-![A diagram showcasing an example of how data models from the Cart and Order modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1728375735/Medusa%20Resources/cart-order_ijwmfs.jpg)
+To retrieve the region of a cart with [Query](!docs!/learn/fundamentals/module-links/query), pass `region.*` in `fields`:
+
+
+
+
+```ts
+const { data: carts } = await query.graph({
+ entity: "cart",
+ fields: [
+ "region.*"
+ ]
+})
+
+// carts.region
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: carts } = useQueryGraphStep({
+ entity: "cart",
+ fields: [
+ "region.*"
+ ]
+})
+
+// carts.region
+```
+
+
+
+
+---
+
+## Sales Channel Module
+
+Medusa defines a read-only link between the `Cart` data model and the [Sales Channel Module](../../sales-channel/page.mdx)'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](!docs!/learn/fundamentals/module-links/query), pass `sales_channel.*` in `fields`:
+
+
+
+
+```ts
+const { data: carts } = await query.graph({
+ entity: "cart",
+ fields: [
+ "sales_channel.*"
+ ]
+})
+
+// carts.sales_channel
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: carts } = useQueryGraphStep({
+ entity: "cart",
+ fields: [
+ "sales_channel.*"
+ ]
+})
+
+// carts.sales_channel
+```
+
+
+
diff --git a/www/apps/resources/app/commerce-modules/currency/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/currency/links-to-other-modules/page.mdx
new file mode 100644
index 0000000000000..2ea00ee4de647
--- /dev/null
+++ b/www/apps/resources/app/commerce-modules/currency/links-to-other-modules/page.mdx
@@ -0,0 +1,68 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
+export const metadata = {
+ title: `Links between Currency Module and Other Modules`,
+}
+
+# {metadata.title}
+
+This document showcases the module links defined between the Currency Module and other commerce modules.
+
+## Summary
+
+The Currency 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.
+
+
+
+- [`Currency` data model of Store Module \<\> `Currency` data model of Currency Module](#store-module). (Read-only).
+
+---
+
+## Store Module
+
+The Store Module has a `Currency` data model that stores the supported currencies of a store. However, these currencies don't hold all the details of a currency, such as its name or symbol.
+
+Instead, Medusa defines a read-only link between the Currency Module's `Currency` data model and the [Store Module](../../store/page.mdx)'s `Currency` data model. This means you can retrieve the details of a store's supported currencies, but you don't manage the links in a pivot table in the database. The currencies of a store are determined by the `currency_code` of the `Currency` data model in the Store Module.
+
+### Retrieve with Query
+
+To retrieve the details of a store's currencies with [Query](!docs!/learn/fundamentals/module-links/query), pass `supported_currencies.currency.*` in `fields`:
+
+
+
+
+```ts
+const { data: stores } = await query.graph({
+ entity: "store",
+ fields: [
+ "supported_currencies.currency.*"
+ ]
+})
+
+// stores.supported_currencies
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: stores } = useQueryGraphStep({
+ entity: "store",
+ fields: [
+ "supported_currencies.currency.*"
+ ]
+})
+
+// stores.supported_currencies
+```
+
+
+
diff --git a/www/apps/resources/app/commerce-modules/customer/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/customer/links-to-other-modules/page.mdx
new file mode 100644
index 0000000000000..7dac5330fe47d
--- /dev/null
+++ b/www/apps/resources/app/commerce-modules/customer/links-to-other-modules/page.mdx
@@ -0,0 +1,112 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
+export const metadata = {
+ title: `Links between Customer Module and Other Modules`,
+}
+
+# {metadata.title}
+
+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:
+
+
+
+Read-only links are used to query data across modules, but the relations aren't stored in a pivot table in the database.
+
+
+
+- [`Cart` data model of Cart Module \<\> `Customer` data model](#cart-module). (Read-only).
+- [`Order` data model of Order Module \<\> `Customer` data model](#order-module). (Read-only).
+
+---
+
+## Cart Module
+
+Medusa defines a read-only link between the `Customer` data model and the [Cart Module](../../cart/page.mdx)'s `Cart` data model. This means you can retrieve the details of a customer's carts, 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 a customer's carts with [Query](!docs!/learn/fundamentals/module-links/query), pass `carts.*` in `fields`:
+
+
+
+
+```ts
+const { data: customers } = await query.graph({
+ entity: "customer",
+ fields: [
+ "carts.*"
+ ]
+})
+
+// customers.carts
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: customers } = useQueryGraphStep({
+ entity: "customer",
+ fields: [
+ "carts.*"
+ ]
+})
+
+// customers.carts
+```
+
+
+
+
+---
+
+## Order Module
+
+Medusa defines a read-only link between the `Customer` data model and the [Order Module](../../order/page.mdx)'s `Order` data model. This means you can retrieve the details of a customer's orders, 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 a customer's orders with [Query](!docs!/learn/fundamentals/module-links/query), pass `orders.*` in `fields`:
+
+
+
+
+```ts
+const { data: customers } = await query.graph({
+ entity: "customer",
+ fields: [
+ "orders.*"
+ ]
+})
+
+// customers.orders
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: customers } = useQueryGraphStep({
+ entity: "customer",
+ fields: [
+ "orders.*"
+ ]
+})
+
+// customers.orders
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/fulfillment/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/fulfillment/links-to-other-modules/page.mdx
index 461f24493758f..234ac7d107c3e 100644
--- a/www/apps/resources/app/commerce-modules/fulfillment/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/fulfillment/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Fulfillment Module and Other Modules`,
}
@@ -6,9 +8,21 @@ export const metadata = {
This document showcases the module links defined between the Fulfillment Module and other commerce modules.
+## Summary
+
+The Fulfillment Module has the following links to other modules:
+
+- [`Order` data model of the Order Module \<\> `Fulfillment` data model](#order-module).
+- [`Return` data model of the Order Module \<\> `Fulfillment` data model](#order-module).
+- [`PriceSet` data model of the Pricing Module \<\> `ShippingOption` data model](#pricing-module).
+- [`StockLocation` data model of the Stock Location Module \<\> `FulfillmentProvider` data model](#stock-location-module).
+- [`StockLocation` data model of the Stock Location Module \<\> `FulfillmentSet` data model](#stock-location-module).
+
+---
+
## Order Module
-The Order Module provides order-management functionalities.
+The [Order Module](../../order/page.mdx) provides order-management functionalities.
Medusa defines a link between the `Fulfillment` and `Order` data models. A fulfillment is created for an orders' items.
@@ -18,6 +32,95 @@ A fulfillment is also created for a return's items. So, Medusa defines a link be
![A diagram showcasing an example of how data models from the Fulfillment and Order modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1728399052/Medusa%20Resources/Social_Media_Graphics_2024_Order_Return_vetimk.jpg)
+### Retrieve with Query
+
+To retrieve the order of a fulfillment with [Query](!docs!/learn/fundamentals/module-links/query), pass `order.*` in `fields`:
+
+
+
+To retrieve the return, pass `return.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: fulfillments } = await query.graph({
+ entity: "fulfillment",
+ fields: [
+ "order.*"
+ ]
+})
+
+// fulfillments.order
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: fulfillments } = useQueryGraphStep({
+ entity: "fulfillment",
+ fields: [
+ "order.*"
+ ]
+})
+
+// fulfillments.order
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the order of a cart, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.FULFILLMENT]: {
+ fulfillment_id: "ful_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.FULFILLMENT]: {
+ fulfillment_id: "ful_123",
+ },
+})
+```
+
+
+
+
---
## Pricing Module
@@ -28,6 +131,89 @@ Medusa defines a link between the `PriceSet` and `ShippingOption` data models. A
![A diagram showcasing an example of how data models from the Pricing and Fulfillment modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716561747/Medusa%20Resources/pricing-fulfillment_spywwa.jpg)
+### Retrieve with Query
+
+To retrieve the price set of a shipping option with [Query](!docs!/learn/fundamentals/module-links/query), pass `price_set.*` in `fields`:
+
+
+
+
+```ts
+const { data: shippingOptions } = await query.graph({
+ entity: "shipping_option",
+ fields: [
+ "price_set.*"
+ ]
+})
+
+// shippingOptions.price_set
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: shippingOptions } = useQueryGraphStep({
+ entity: "shipping_option",
+ fields: [
+ "price_set.*"
+ ]
+})
+
+// shippingOptions.price_set
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the price set of a shipping option, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.FULFILLMENT]: {
+ shipping_option_id: "so_123",
+ },
+ [Modules.PRICING]: {
+ price_set_id: "pset_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.FULFILLMENT]: {
+ shipping_option_id: "so_123",
+ },
+ [Modules.PRICING]: {
+ price_set_id: "pset_123",
+ },
+})
+```
+
+
+
+
---
## Stock Location Module
@@ -41,3 +227,92 @@ Medusa defines a link between the `FulfillmentSet` and `StockLocation` data mode
Medusa also defines a link between the `FulfillmentProvider` and `StockLocation` data models to indicate the providers that can be used in a location.
![A diagram showcasing an example of how data models from the Fulfillment and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1728399492/Medusa%20Resources/fulfillment-provider-stock-location_b0mulo.jpg)
+
+### Retrieve with Query
+
+To retrieve the stock location of a fulfillment set with [Query](!docs!/learn/fundamentals/module-links/query), pass `location.*` in `fields`:
+
+
+
+To retrieve the stock location of a fulfillment provider, pass `locations.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: fulfillmentSets } = await query.graph({
+ entity: "fulfillment_set",
+ fields: [
+ "location.*"
+ ]
+})
+
+// fulfillmentSets.location
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: fulfillmentSets } = useQueryGraphStep({
+ entity: "fulfillment_set",
+ fields: [
+ "location.*"
+ ]
+})
+
+// fulfillmentSets.location
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the stock location of a fulfillment set, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.STOCK_LOCATION]: {
+ stock_location_id: "sloc_123",
+ },
+ [Modules.FULFILLMENT]: {
+ fulfillment_set_id: "fset_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.STOCK_LOCATION]: {
+ stock_location_id: "sloc_123",
+ },
+ [Modules.FULFILLMENT]: {
+ fulfillment_set_id: "fset_123",
+ },
+})
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/inventory/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/inventory/links-to-other-modules/page.mdx
index 56aed72916c94..2b8f3134c9173 100644
--- a/www/apps/resources/app/commerce-modules/inventory/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/inventory/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Inventory Module and Other Modules`,
}
@@ -6,6 +8,21 @@ export const metadata = {
This document showcases the module links defined between the Inventory Module and other commerce modules.
+## Summary
+
+The Inventory 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.
+
+
+
+- [`ProductVariant` data model of Product Module \<\> `InventoryItem` data model](#product-module).
+- [`InventoryLevel` data model \<\> `StockLocation` data model of Stock Location Module](#stock-location-module). (Read-only).
+
+---
+
## Product Module
Each product variant has different inventory details. Medusa defines a link between the `ProductVariant` and `InventoryItem` data models.
@@ -13,3 +30,131 @@ Each product variant has different inventory details. Medusa defines a link betw
![A diagram showcasing an example of how data models from the Inventory and Product Module are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1709658720/Medusa%20Resources/inventory-product_ejnray.jpg)
A product variant whose `manage_inventory` property is enabled has an associated inventory item. Through that inventory's items relations in the Inventory Module, you can manage and check the variant's inventory quantity.
+
+### Retrieve with Query
+
+To retrieve the product variants of an inventory item with [Query](!docs!/learn/fundamentals/module-links/query), pass `variants.*` in `fields`:
+
+
+
+
+```ts
+const { data: inventoryItems } = await query.graph({
+ entity: "inventory_item",
+ fields: [
+ "variants.*"
+ ]
+})
+
+// inventoryItems.variants
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: inventoryItems } = useQueryGraphStep({
+ entity: "inventory_item",
+ fields: [
+ "variants.*"
+ ]
+})
+
+// inventoryItems.variants
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the variants of an inventory item, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.PRODUCT]: {
+ variant_id: "variant_123",
+ },
+ [Modules.INVENTORY]: {
+ inventory_item_id: "iitem_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.PRODUCT]: {
+ variant_id: "variant_123",
+ },
+ [Modules.INVENTORY]: {
+ inventory_item_id: "iitem_123",
+ },
+})
+```
+
+
+
+
+---
+
+## Stock Location Module
+
+Medusa defines a read-only link between the `InventoryLevel` data model and the [Stock Location Module](../../stock-location/page.mdx)'s `StockLocation` data model. This means you can retrieve the details of an inventory level's stock locations, but you don't manage the links in a pivot table in the database. The stock location of an inventory level is determined by the `location_id` property of the `InventoryLevel` data model.
+
+### Retrieve with Query
+
+To retrieve the stock locations of an inventory level with [Query](!docs!/learn/fundamentals/module-links/query), pass `stock_locations.*` in `fields`:
+
+
+
+
+```ts
+const { data: inventoryLevels } = await query.graph({
+ entity: "inventory_level",
+ fields: [
+ "stock_locations.*"
+ ]
+})
+
+// inventoryLevels.stock_locations
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: inventoryLevels } = useQueryGraphStep({
+ entity: "inventory_level",
+ fields: [
+ "stock_locations.*"
+ ]
+})
+
+// inventoryLevels.stock_locations
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/order/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/order/links-to-other-modules/page.mdx
index 51c04104376b5..07c028281bada 100644
--- a/www/apps/resources/app/commerce-modules/order/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/order/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Order Module and Other Modules`,
}
@@ -6,14 +8,166 @@ export const metadata = {
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:
+
+
+
+Read-only links are used to query data across modules, but the relations aren't stored in a pivot table in the database.
+
+
+
+- [`Order` data model \<\> `Customer` data model of Customer Module](#customer-module). (Read-only).
+- [`Order` data model \<\> `Cart` data model of Cart Module](#cart-module).
+- [`Order` data model \<\> `Fulfillment` data model of Fulfillment Module](#fulfillment-module).
+- [`Return` data model \<\> `Fulfillment` data model of Fulfillment Module](#fulfillment-module).
+- [`Order` data model \<\> `PaymentCollection` data model of Payment Module](#payment-module).
+- [`OrderClaim` data model \<\> `PaymentCollection` data model of Payment Module](#payment-module).
+- [`OrderExchange` data model \<\> `PaymentCollection` data model of Payment Module](#payment-module).
+- [`Order` data model \<\> `Product` data model of Product Module](#product-module). (Read-only).
+- [`Order` data model \<\> `Promotion` data model of Promotion Module](#promotion-module).
+- [`Order` data model \<\> `Region` data model of Region Module](#region-module). (Read-only).
+- [`Order` data model \<\> `SalesChannel` data model of Sales Channel Module](#sales-channel-module). (Read-only).
+
+---
+
+## Customer Module
+
+Medusa defines a read-only link between the `Order` data model and the [Customer Module](../../customer/page.mdx)'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](!docs!/learn/fundamentals/module-links/query), pass `customer.*` in `fields`:
+
+
+
+
+```ts
+const { data: orders } = await query.graph({
+ entity: "order",
+ fields: [
+ "customer.*"
+ ]
+})
+
+// orders.customer
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: orders } = useQueryGraphStep({
+ entity: "order",
+ fields: [
+ "customer.*"
+ ]
+})
+
+// orders.customer
+```
+
+
+
+
+---
+
## Cart Module
-The Cart Module provides cart-management features.
+The [Cart Module](../../cart/page.mdx) 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](https://res.cloudinary.com/dza7lstvk/image/upload/v1728375735/Medusa%20Resources/cart-order_ijwmfs.jpg)
+### Retrieve with Query
+
+To retrieve the cart of an order with [Query](!docs!/learn/fundamentals/module-links/query), pass `cart.*` in `fields`:
+
+
+
+
+```ts
+const { data: orders } = await query.graph({
+ entity: "order",
+ fields: [
+ "cart.*"
+ ]
+})
+
+// orders.cart
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: orders } = useQueryGraphStep({
+ entity: "order",
+ fields: [
+ "cart.*"
+ ]
+})
+
+// orders.cart
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the cart of an order, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.CART]: {
+ cart_id: "cart_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.CART]: {
+ cart_id: "cart_123",
+ },
+})
+```
+
+
+
+
---
## Fulfillment Module
@@ -22,11 +176,99 @@ A fulfillment is created for an orders' items. Medusa defines a link between the
![A diagram showcasing an example of how data models from the Fulfillment and Order modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716549903/Medusa%20Resources/order-fulfillment_h0vlps.jpg)
-
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](https://res.cloudinary.com/dza7lstvk/image/upload/v1728399052/Medusa%20Resources/Social_Media_Graphics_2024_Order_Return_vetimk.jpg)
+### Retrieve with Query
+
+To retrieve the fulfillments of an order with [Query](!docs!/learn/fundamentals/module-links/query), pass `fulfillments.*` in `fields`:
+
+
+
+To retrieve the fulfillments of a return, pass `fulfillments.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: orders } = await query.graph({
+ entity: "order",
+ fields: [
+ "fulfillments.*"
+ ]
+})
+
+// orders.fulfillments
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: orders } = useQueryGraphStep({
+ entity: "order",
+ fields: [
+ "fulfillments.*"
+ ]
+})
+
+// orders.fulfillments
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the fulfillments of an order, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.FULFILLMENT]: {
+ fulfillment_id: "ful_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.FULFILLMENT]: {
+ fulfillment_id: "ful_123",
+ },
+})
+```
+
+
+
+
---
## Payment Module
@@ -37,6 +279,143 @@ So, Medusa defines links between the `PaymentCollection` data model and the `Ord
![A diagram showcasing an example of how data models from the Order and Payment modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716554726/Medusa%20Resources/order-payment_ubdwok.jpg)
+### Retrieve with Query
+
+To retrieve the payment collections of an order, order exchange, or order claim with [Query](!docs!/learn/fundamentals/module-links/query), pass `payment_collections.*` in `fields`:
+
+
+
+
+```ts
+const { data: orders } = await query.graph({
+ entity: "order",
+ fields: [
+ "payment_collections.*"
+ ]
+})
+
+// orders.payment_collections
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: orders } = useQueryGraphStep({
+ entity: "order",
+ fields: [
+ "payment_collections.*"
+ ]
+})
+
+// orders.payment_collections
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the payment collections of an order, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_collection_id: "paycol_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_collection_id: "paycol_123",
+ },
+})
+```
+
+
+
+
+---
+
+## Product Module
+
+Medusa defines read-only links between:
+
+- the `OrderLineItem` data model and the [Product Module](../../product/page.mdx)'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](../../product/page.mdx)'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](!docs!/learn/fundamentals/module-links/query), pass `variant.*` in `fields`:
+
+
+
+To retrieve the product, pass `product.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: lineItems } = await query.graph({
+ entity: "order_line_item",
+ fields: [
+ "variant.*"
+ ]
+})
+
+// lineItems.variant
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: lineItems } = useQueryGraphStep({
+ entity: "order_line_item",
+ fields: [
+ "variant.*"
+ ]
+})
+
+// lineItems.variant
+```
+
+
+
+
---
## Promotion Module
@@ -44,3 +423,176 @@ So, Medusa defines links between the `PaymentCollection` data model and the `Ord
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](https://res.cloudinary.com/dza7lstvk/image/upload/v1716555015/Medusa%20Resources/order-promotion_dgjzzd.jpg)
+
+### Retrieve with Query
+
+To retrieve the promotion applied on an order with [Query](!docs!/learn/fundamentals/module-links/query), pass `promotion.*` in `fields`:
+
+
+
+
+```ts
+const { data: orders } = await query.graph({
+ entity: "order",
+ fields: [
+ "promotion.*"
+ ]
+})
+
+// orders.promotion
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: orders } = useQueryGraphStep({
+ entity: "order",
+ fields: [
+ "promotion.*"
+ ]
+})
+
+// orders.promotion
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the promotion of an order, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.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",
+ },
+})
+```
+
+
+
+
+---
+
+## Region Module
+
+Medusa defines a read-only link between the `Order` data model and the [Region Module](../../region/page.mdx)'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](!docs!/learn/fundamentals/module-links/query), pass `region.*` in `fields`:
+
+
+
+
+```ts
+const { data: orders } = await query.graph({
+ entity: "order",
+ fields: [
+ "region.*"
+ ]
+})
+
+// orders.region
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: orders } = useQueryGraphStep({
+ entity: "order",
+ fields: [
+ "region.*"
+ ]
+})
+
+// orders.region
+```
+
+
+
+
+---
+
+## Sales Channel Module
+
+Medusa defines a read-only link between the `Order` data model and the [Sales Channel Module](../../sales-channel/page.mdx)'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](!docs!/learn/fundamentals/module-links/query), pass `sales_channel.*` in `fields`:
+
+
+
+
+```ts
+const { data: orders } = await query.graph({
+ entity: "order",
+ fields: [
+ "sales_channel.*"
+ ]
+})
+
+// orders.sales_channel
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: orders } = useQueryGraphStep({
+ entity: "order",
+ fields: [
+ "sales_channel.*"
+ ]
+})
+
+// orders.sales_channel
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/payment/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/payment/links-to-other-modules/page.mdx
index 5e32a58e64202..14af06d51b994 100644
--- a/www/apps/resources/app/commerce-modules/payment/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/payment/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Payment Module and Other Modules`,
}
@@ -6,6 +8,18 @@ export const metadata = {
This document showcases the module links defined between the Payment Module and other commerce modules.
+## Summary
+
+The Payment Module has the following links to other modules:
+
+- [`Cart` data model of Cart Module \<\> `PaymentCollection` data model](#cart-module).
+- [`Order` data model of Order Module \<\> `PaymentCollection` data model](#order-module).
+- [`OrderClaim` data model of Order Module \<\> `PaymentCollection` data model](#order-module).
+- [`OrderExchange` data model of Order Module \<\> `PaymentCollection` data model](#order-module).
+- [`Region` data model of Region Module \<\> `PaymentProvider` data model](#region-module).
+
+---
+
## Cart Module
The Cart Module provides cart-related features, but not payment processing.
@@ -14,6 +28,88 @@ Medusa defines a link between the `Cart` and `PaymentCollection` data models. A
Learn more about this relation in [this documentation](../payment-collection/page.mdx#usage-with-the-cart-module).
+### Retrieve with Query
+
+To retrieve the cart associated with the payment collection with [Query](!docs!/learn/fundamentals/module-links/query), pass `cart.*` in `fields`:
+
+
+
+
+```ts
+const { data: paymentCollections } = await query.graph({
+ entity: "payment_collection",
+ fields: [
+ "cart.*"
+ ]
+})
+
+// paymentCollections.cart
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: paymentCollections } = useQueryGraphStep({
+ entity: "payment_collection",
+ fields: [
+ "cart.*"
+ ]
+})
+
+// paymentCollections.cart
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the payment collection of a cart, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.CART]: {
+ cart_id: "cart_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_collection_id: "paycol_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.CART]: {
+ cart_id: "cart_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_collection_id: "paycol_123",
+ },
+})
+```
+
+
+
+
---
## Order Module
@@ -24,6 +120,89 @@ So, Medusa defines links between the `PaymentCollection` data model and the `Ord
![A diagram showcasing an example of how data models from the Order and Payment modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716554726/Medusa%20Resources/order-payment_ubdwok.jpg)
+### Retrieve with Query
+
+To retrieve the order of a payment collection with [Query](!docs!/learn/fundamentals/module-links/query), pass `order.*` in `fields`:
+
+
+
+
+```ts
+const { data: paymentCollections } = await query.graph({
+ entity: "payment_collection",
+ fields: [
+ "order.*"
+ ]
+})
+
+// paymentCollections.order
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: paymentCollections } = useQueryGraphStep({
+ entity: "payment_collection",
+ fields: [
+ "order.*"
+ ]
+})
+
+// paymentCollections.order
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the payment collections of an order, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_collection_id: "paycol_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.ORDER]: {
+ order_id: "order_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_collection_id: "paycol_123",
+ },
+})
+```
+
+
+
+
---
## Region Module
@@ -33,3 +212,86 @@ You can specify for each region which payment providers are available. The Medus
![A diagram showcasing an example of how resources from the Payment and Region modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1711569520/Medusa%20Resources/payment-region_jyo2dz.jpg)
This increases the flexibility of your store. For example, you only show during checkout the payment providers associated with the cart's region.
+
+### Retrieve with Query
+
+To retrieve the regions of a payment provider with [Query](!docs!/learn/fundamentals/module-links/query), pass `regions.*` in `fields`:
+
+
+
+
+```ts
+const { data: paymentProviders } = await query.graph({
+ entity: "payment_provider",
+ fields: [
+ "regions.*"
+ ]
+})
+
+// paymentProviders.regions
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: paymentProviders } = useQueryGraphStep({
+ entity: "payment_provider",
+ fields: [
+ "regions.*"
+ ]
+})
+
+// paymentProviders.regions
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the payment providers in a region, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.REGION]: {
+ region_id: "reg_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_provider_id: "pp_stripe_stripe",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.REGION]: {
+ region_id: "reg_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_provider_id: "pp_stripe_stripe",
+ },
+})
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/pricing/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/pricing/links-to-other-modules/page.mdx
index debc6df062fc6..5fb0e16c403b6 100644
--- a/www/apps/resources/app/commerce-modules/pricing/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/pricing/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Pricing Module and Other Modules`,
}
@@ -6,6 +8,15 @@ export const metadata = {
This document showcases the module links defined between the Pricing Module and other commerce modules.
+## Summary
+
+The Pricing Module has the following links to other modules:
+
+- [`ShippingOption` data model of Fulfillment Module \<\> `PriceSet` data model](#fulfillment-module).
+- [`ProductVariant` data model of Product Module \<\> `PriceSet` data model](#product-module).
+
+---
+
## Fulfillment Module
The Fulfillment Module provides fulfillment-related functionalities, including shipping options that the customer chooses from when they place their order. However, it doesn't provide pricing-related functionalities for these options.
@@ -14,6 +25,89 @@ Medusa defines a link between the `PriceSet` and `ShippingOption` data models. A
![A diagram showcasing an example of how data models from the Pricing and Fulfillment modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716561747/Medusa%20Resources/pricing-fulfillment_spywwa.jpg)
+### Retrieve with Query
+
+To retrieve the shipping option of a price set with [Query](!docs!/learn/fundamentals/module-links/query), pass `shipping_option.*` in `fields`:
+
+
+
+
+```ts
+const { data: priceSets } = await query.graph({
+ entity: "price_set",
+ fields: [
+ "shipping_option.*"
+ ]
+})
+
+// priceSets.shipping_option
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: priceSets } = useQueryGraphStep({
+ entity: "price_set",
+ fields: [
+ "shipping_option.*"
+ ]
+})
+
+// priceSets.shipping_option
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the price set of a shipping option, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.FULFILLMENT]: {
+ shipping_option_id: "so_123",
+ },
+ [Modules.PRICING]: {
+ price_set_id: "pset_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.FULFILLMENT]: {
+ shipping_option_id: "so_123",
+ },
+ [Modules.PRICING]: {
+ price_set_id: "pset_123",
+ },
+})
+```
+
+
+
+
---
## Product Module
@@ -27,3 +121,86 @@ Medusa defines a link between the `ProductVariant` and the `PriceSet`. A product
So, when you want to add prices for a product variant, you create a price set and add the prices to it.
You can then benefit from adding rules to prices or using the `calculatePrices` method to retrieve the price of a product variant within a specified context.
+
+### Retrieve with Query
+
+To retrieve the variant of a price set with [Query](!docs!/learn/fundamentals/module-links/query), pass `variant.*` in `fields`:
+
+
+
+
+```ts
+const { data: priceSets } = await query.graph({
+ entity: "price_set",
+ fields: [
+ "variant.*"
+ ]
+})
+
+// priceSets.variant
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: priceSets } = useQueryGraphStep({
+ entity: "price_set",
+ fields: [
+ "variant.*"
+ ]
+})
+
+// priceSets.variant
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the price set of a variant, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.PRODUCT]: {
+ variant_id: "variant_123",
+ },
+ [Modules.PRICING]: {
+ price_set_id: "pset_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.PRODUCT]: {
+ variant_id: "variant_123",
+ },
+ [Modules.PRICING]: {
+ price_set_id: "pset_123",
+ },
+})
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/product/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/product/links-to-other-modules/page.mdx
index d4c39b7f4370b..04fd9fedbf21d 100644
--- a/www/apps/resources/app/commerce-modules/product/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/product/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Product Module and Other Modules`,
}
@@ -6,6 +8,227 @@ export const metadata = {
This document showcases the module links defined between the Product Module and other commerce modules.
+## Summary
+
+The Product 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.
+
+
+
+- [`Product` data model \<\> `Cart` data model of Cart Module](#cart-module). (Read-only).
+- [`Product` data model \<\> `InventoryItem` data model of Inventory Module](#inventory-module).
+- [`Product` data model \<\> `Order` data model of Order Module](#order-module). (Read-only).
+- [`ProductVariant` data model \<\> `PriceSet` data model of Pricing Module](#pricing-module).
+- [`Product` data model \<\> `SalesChannel` data model of Sales Channel Module](#sales-channel-module).
+
+---
+
+## Cart Module
+
+Medusa defines read-only links between:
+
+- The `Product` data model and the [Cart Module](../../cart/page.mdx)'s `LineItem` 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 `ProductVariant` data model and the [Cart Module](../../cart/page.mdx)'s `LineItem` 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 line items of a variant with [Query](!docs!/learn/fundamentals/module-links/query), pass `line_items.*` in `fields`:
+
+
+
+To retrieve the line items of a product, pass `line_items.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: variants } = await query.graph({
+ entity: "variant",
+ fields: [
+ "line_items.*"
+ ]
+})
+
+// variants.line_items
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: variants } = useQueryGraphStep({
+ entity: "variant",
+ fields: [
+ "line_items.*"
+ ]
+})
+
+// variants.line_items
+```
+
+
+
+
+---
+
+## Inventory Module
+
+The Inventory Module provides inventory-management features for any stock-kept item.
+
+Medusa defines a link between the `ProductVariant` and `InventoryItem` data models. Each product variant has different inventory details.
+
+![A diagram showcasing an example of how data models from the Product and Inventory modules are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1709652779/Medusa%20Resources/product-inventory_kmjnud.jpg)
+
+When the `manage_inventory` property of a product variant is enabled, you can manage the variant's inventory in different locations through this relation.
+
+### Retrieve with Query
+
+To retrieve the inventory items of a product variant with [Query](!docs!/learn/fundamentals/module-links/query), pass `inventory_items.*` in `fields`:
+
+
+
+
+```ts
+const { data: variants } = await query.graph({
+ entity: "variant",
+ fields: [
+ "inventory_items.*"
+ ]
+})
+
+// variants.inventory_items
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: variants } = useQueryGraphStep({
+ entity: "variant",
+ fields: [
+ "inventory_items.*"
+ ]
+})
+
+// variants.inventory_items
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the inventory items of a variant, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.PRODUCT]: {
+ variant_id: "variant_123",
+ },
+ [Modules.INVENTORY]: {
+ inventory_item_id: "iitem_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.PRODUCT]: {
+ variant_id: "variant_123",
+ },
+ [Modules.INVENTORY]: {
+ inventory_item_id: "iitem_123",
+ },
+})
+```
+
+
+
+
+---
+
+## Order Module
+
+Medusa defines read-only links between:
+
+- the `Product` data model and the [Order Module](../../order/page.mdx)'s `OrderLineItem` 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 `ProductVariant` data model and the [Order Module](../../order/page.mdx)'s `OrderLineItem` 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 order line items of a variant with [Query](!docs!/learn/fundamentals/module-links/query), pass `order_items.*` in `fields`:
+
+
+
+To retrieve a product's order line items, pass `order_items.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: variants } = await query.graph({
+ entity: "variant",
+ fields: [
+ "order_items.*"
+ ]
+})
+
+// variants.order_items
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: variants } = useQueryGraphStep({
+ entity: "variant",
+ fields: [
+ "order_items.*"
+ ]
+})
+
+// variants.order_items
+```
+
+
+
+
+---
+
## Pricing Module
The Product Module doesn't provide pricing-related features.
@@ -16,6 +239,89 @@ Instead, Medusa defines a link between the `ProductVariant` and the `PriceSet` d
So, to add prices for a product variant, create a price set and add the prices to it.
+### Retrieve with Query
+
+To retrieve the price set of a variant with [Query](!docs!/learn/fundamentals/module-links/query), pass `price_set.*` in `fields`:
+
+
+
+
+```ts
+const { data: variants } = await query.graph({
+ entity: "variant",
+ fields: [
+ "price_set.*"
+ ]
+})
+
+// variants.price_set
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: variants } = useQueryGraphStep({
+ entity: "variant",
+ fields: [
+ "price_set.*"
+ ]
+})
+
+// variants.price_set
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the price set of a variant, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.PRODUCT]: {
+ variant_id: "variant_123",
+ },
+ [Modules.PRICING]: {
+ price_set_id: "pset_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.PRODUCT]: {
+ variant_id: "variant_123",
+ },
+ [Modules.PRICING]: {
+ price_set_id: "pset_123",
+ },
+})
+```
+
+
+
+
---
## Sales Channel Module
@@ -26,14 +332,85 @@ Medusa defines a link between the `Product` and `SalesChannel` data models. A pr
![A diagram showcasing an example of how data models from the Product and Sales Channel modules are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1709651840/Medusa%20Resources/product-sales-channel_t848ik.jpg)
----
+### Retrieve with Query
-## Inventory Module
+To retrieve the sales channels of a product with [Query](!docs!/learn/fundamentals/module-links/query), pass `sales_channels.*` in `fields`:
-The Inventory Module provides inventory-management features for any stock-kept item.
+
+
-Medusa defines a link between the `ProductVariant` and `InventoryItem` data models. Each product variant has different inventory details.
+```ts
+const { data: products } = await query.graph({
+ entity: "product",
+ fields: [
+ "sales_channels.*"
+ ]
+})
-![A diagram showcasing an example of how data models from the Product and Inventory modules are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1709652779/Medusa%20Resources/product-inventory_kmjnud.jpg)
+// products.sales_channels
+```
-When the `manage_inventory` property of a product variant is enabled, you can manage the variant's inventory in different locations through this relation.
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: products } = useQueryGraphStep({
+ entity: "product",
+ fields: [
+ "sales_channels.*"
+ ]
+})
+
+// products.sales_channels
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the sales channels of a product, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.PRODUCT]: {
+ product_id: "prod_123",
+ },
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.PRODUCT]: {
+ product_id: "prod_123",
+ },
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+})
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/promotion/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/promotion/links-to-other-modules/page.mdx
index c81834fbee8e6..356a3f9134f67 100644
--- a/www/apps/resources/app/commerce-modules/promotion/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/promotion/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Promotion Module and Other Modules`,
}
@@ -6,16 +8,206 @@ export const metadata = {
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.
+
+
+
+- [`Cart` data model of the Cart Module \<\> `Promotion` data model](#cart-module).
+- [`LineItemAdjustment` data model of the Cart Module \<\> `Promotion` data model](#cart-module). (Read-only).
+- [`Order` data model of the Order Module \<\> `Promotion` data model](#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`, `LineItemAdjustment`, and `Promotion` data models.
+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](https://res.cloudinary.com/dza7lstvk/image/upload/v1711538015/Medusa%20Resources/cart-promotion_kuh9vm.jpg)
+Medusa also defines a read-only link between the `Promotion` data model and the [Cart Module](../../cart/page.mdx)'s `LineItemAdjustment` data model. 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 carts that a promotion is applied on with [Query](!docs!/learn/fundamentals/module-links/query), pass `carts.*` in `fields`:
+
+
+
+To retrieve the line item adjustments of a promotion, pass `line_item_adjustments.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: promotions } = await query.graph({
+ entity: "promotion",
+ fields: [
+ "carts.*"
+ ]
+})
+
+// promotions.carts
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: promotions } = useQueryGraphStep({
+ entity: "promotion",
+ fields: [
+ "carts.*"
+ ]
+})
+
+// promotions.carts
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the promotions of a cart, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.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.
-![A diagram showcasing an example of how data models from the Order and Promotion modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716555015/Medusa%20Resources/order-promotion_dgjzzd.jpg)
\ No newline at end of file
+![A diagram showcasing an example of how data models from the Order and Promotion modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716555015/Medusa%20Resources/order-promotion_dgjzzd.jpg)
+
+### 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.orders
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: promotions } = useQueryGraphStep({
+ entity: "promotion",
+ fields: [
+ "orders.*"
+ ]
+})
+
+// promotions.orders
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the promotion of an order, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.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",
+ },
+})
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/region/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/region/links-to-other-modules/page.mdx
index a3cd4b4a866d5..08881435999fd 100644
--- a/www/apps/resources/app/commerce-modules/region/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/region/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Region Module and Other Modules`,
}
@@ -6,6 +8,112 @@ export const metadata = {
This document showcases the module links defined between the Region Module and other commerce modules.
+## Summary
+
+The Region 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.
+
+
+
+- [`Region` data model \<\> `Cart` data model of the Cart Module](#cart-module). (Read-only)
+- [`Region` data model \<\> `Order` data model of the Order Module](#order-module). (Read-only)
+- [`Region` data model \<\> `PaymentProvider` data model of the Payment Module](#payment-module).
+
+---
+
+## Cart Module
+
+Medusa defines a read-only link between the `Region` data model and the [Cart Module](../../cart/page.mdx)'s `Cart` data model. This means you can retrieve the details of a region's carts, 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 carts of a region with [Query](!docs!/learn/fundamentals/module-links/query), pass `carts.*` in `fields`:
+
+
+
+
+```ts
+const { data: regions } = await query.graph({
+ entity: "region",
+ fields: [
+ "carts.*"
+ ]
+})
+
+// regions.carts
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: regions } = useQueryGraphStep({
+ entity: "region",
+ fields: [
+ "carts.*"
+ ]
+})
+
+// regions.carts
+```
+
+
+
+
+---
+
+## Order Module
+
+Medusa defines a read-only link between the `Region` data model and the [Cart Module](../../cart/page.mdx)'s `Cart` data model. This means you can retrieve the details of a region's orders, 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 orders of a region with [Query](!docs!/learn/fundamentals/module-links/query), pass `orders.*` in `fields`:
+
+
+
+
+```ts
+const { data: regions } = await query.graph({
+ entity: "region",
+ fields: [
+ "orders.*"
+ ]
+})
+
+// regions.orders
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: regions } = useQueryGraphStep({
+ entity: "region",
+ fields: [
+ "orders.*"
+ ]
+})
+
+// regions.orders
+```
+
+
+
+
+---
+
## Payment Module
You can specify for each region which payment providers are available for use.
@@ -13,3 +121,86 @@ You can specify for each region which payment providers are available for use.
Medusa defines a module link between the `PaymentProvider` and the `Region` data models.
![A diagram showcasing an example of how resources from the Payment and Region modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1711569520/Medusa%20Resources/payment-region_jyo2dz.jpg)
+
+### Retrieve with Query
+
+To retrieve the payment providers of a region with [Query](!docs!/learn/fundamentals/module-links/query), pass `payment_providers.*` in `fields`:
+
+
+
+
+```ts
+const { data: regions } = await query.graph({
+ entity: "region",
+ fields: [
+ "payment_providers.*"
+ ]
+})
+
+// regions.payment_providers
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: regions } = useQueryGraphStep({
+ entity: "region",
+ fields: [
+ "payment_providers.*"
+ ]
+})
+
+// regions.payment_providers
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the payment providers in a region, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.REGION]: {
+ region_id: "reg_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_provider_id: "pp_stripe_stripe",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.REGION]: {
+ region_id: "reg_123",
+ },
+ [Modules.PAYMENT]: {
+ payment_provider_id: "pp_stripe_stripe",
+ },
+})
+```
+
+
+
\ No newline at end of file
diff --git a/www/apps/resources/app/commerce-modules/sales-channel/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/sales-channel/links-to-other-modules/page.mdx
index 379c5869093cd..fb68fb6608c40 100644
--- a/www/apps/resources/app/commerce-modules/sales-channel/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/sales-channel/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Sales Channel Module and Other Modules`,
}
@@ -6,6 +8,24 @@ export const metadata = {
This document showcases the module links defined between the Sales Channel Module and other commerce modules.
+## Summary
+
+The Sales Channel 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.
+
+
+
+- [`ApiKey` data model of the API Key Module \<\> `SalesChannel` data model](#api-key-module).
+- [`SalesChannel` data model \<\> `Cart` data model of the Cart Module](#cart-module). (Read-only)
+- [`SalesChannel` data model \<\> `Order` data model of the Order Module](#order-module). (Read-only)
+- [`Product` data model of the Product Module \<\> `SalesChannel` data model](#product-module).
+- [`SalesChannel` data model \<\> `StockLocation` data model of the Stock Location Module](#stock-location-module).
+
+---
+
## API Key Module
A publishable API key allows you to easily specify the sales channel scope in a client request.
@@ -14,6 +34,179 @@ Medusa defines a link between the `ApiKey` and the `SalesChannel` data models.
![A diagram showcasing an example of how resources from the Sales Channel and API Key modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1709812064/Medusa%20Resources/sales-channel-api-key_zmqi2l.jpg)
+### Retrieve with Query
+
+To retrieve the API keys associated with a sales channel with [Query](!docs!/learn/fundamentals/module-links/query), pass `publishable_api_keys.*` in `fields`:
+
+
+
+
+```ts
+const { data: salesChannels } = await query.graph({
+ entity: "sales_channel",
+ fields: [
+ "publishable_api_keys.*"
+ ]
+})
+
+// salesChannels.publishable_api_keys
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: salesChannels } = useQueryGraphStep({
+ entity: "sales_channel",
+ fields: [
+ "publishable_api_keys.*"
+ ]
+})
+
+// salesChannels.publishable_api_keys
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the sales channels of an API key, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.API_KEY]: {
+ api_key_id: "apk_123",
+ },
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.API_KEY]: {
+ api_key_id: "apk_123",
+ },
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+})
+```
+
+
+
+
+---
+
+## Cart Module
+
+Medusa defines a read-only link between the `SalesChannel` data model and the [Cart Module](../../cart/page.mdx)'s `SalesChannel` data model. This means you can retrieve the details of a sales channel's carts, 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 carts of a sales channel with [Query](!docs!/learn/fundamentals/module-links/query), pass `carts.*` in `fields`:
+
+
+
+
+```ts
+const { data: salesChannels } = await query.graph({
+ entity: "sales_channel",
+ fields: [
+ "carts.*"
+ ]
+})
+
+// salesChannels.carts
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: salesChannels } = useQueryGraphStep({
+ entity: "sales_channel",
+ fields: [
+ "carts.*"
+ ]
+})
+
+// salesChannels.carts
+```
+
+
+
+
+---
+
+## Order Module
+
+Medusa defines a read-only link between the `SalesChannel` data model and the [Order Module](../../order/page.mdx)'s `Order` data model. This means you can retrieve the details of a sales channel's orders, 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 orders of a sales channel with [Query](!docs!/learn/fundamentals/module-links/query), pass `orders.*` in `fields`:
+
+
+
+
+```ts
+const { data: salesChannels } = await query.graph({
+ entity: "sales_channel",
+ fields: [
+ "orders.*"
+ ]
+})
+
+// salesChannels.orders
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: salesChannels } = useQueryGraphStep({
+ entity: "sales_channel",
+ fields: [
+ "orders.*"
+ ]
+})
+
+// salesChannels.orders
+```
+
+
+
+
---
## Product Module
@@ -24,6 +217,89 @@ A product has different availability for different sales channels. Medusa define
A product can be available in more than one sales channel. You can retrieve only the products of a sales channel.
+### Retrieve with Query
+
+To retrieve the products of a sales channel with [Query](!docs!/learn/fundamentals/module-links/query), pass `products.*` in `fields`:
+
+
+
+
+```ts
+const { data: salesChannels } = await query.graph({
+ entity: "sales_channel",
+ fields: [
+ "products.*"
+ ]
+})
+
+// salesChannels.products
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: salesChannels } = useQueryGraphStep({
+ entity: "sales_channel",
+ fields: [
+ "products.*"
+ ]
+})
+
+// salesChannels.products
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the sales channels of a product, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.PRODUCT]: {
+ product_id: "prod_123",
+ },
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.PRODUCT]: {
+ product_id: "prod_123",
+ },
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+})
+```
+
+
+
+
---
## Stock Location Module
@@ -33,3 +309,86 @@ A stock location is associated with a sales channel. This scopes inventory quant
Medusa defines a link between the `SalesChannel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Sales Channel and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716796872/Medusa%20Resources/sales-channel-location_cqrih1.jpg)
+
+### Retrieve with Query
+
+To retrieve the stock locations of a sales channel with [Query](!docs!/learn/fundamentals/module-links/query), pass `stock_locations.*` in `fields`:
+
+
+
+
+```ts
+const { data: salesChannels } = await query.graph({
+ entity: "sales_channel",
+ fields: [
+ "stock_locations.*"
+ ]
+})
+
+// salesChannels.stock_locations
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: salesChannels } = useQueryGraphStep({
+ entity: "sales_channel",
+ fields: [
+ "stock_locations.*"
+ ]
+})
+
+// salesChannels.stock_locations
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the stock locations of a sales channel, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+ [Modules.STOCK_LOCATION]: {
+ sales_channel_id: "sloc_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+ [Modules.STOCK_LOCATION]: {
+ sales_channel_id: "sloc_123",
+ },
+})
+```
+
+
+
diff --git a/www/apps/resources/app/commerce-modules/stock-location/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/stock-location/links-to-other-modules/page.mdx
index 75639acbb0767..1845c552476b5 100644
--- a/www/apps/resources/app/commerce-modules/stock-location/links-to-other-modules/page.mdx
+++ b/www/apps/resources/app/commerce-modules/stock-location/links-to-other-modules/page.mdx
@@ -1,3 +1,5 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
export const metadata = {
title: `Links between Stock Location Module and Other Modules`,
}
@@ -6,6 +8,23 @@ export const metadata = {
This document showcases the module links defined between the Stock Location Module and other commerce modules.
+## Summary
+
+The Stock Location 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.
+
+
+
+- [`FulfillmentSet` data model of the Fulfillment Module \<\> `StockLocation` data model](#fulfillment-module).
+- [`FulfillmentProvider` data model of the Fulfillment Module \<\> `StockLocation` data model](#fulfillment-module).
+- [`StockLocation` data model \<\> `Inventory` data model of the Inventory Module](#inventory-module).
+- [`SalesChannel` data model of the Sales Channel Module \<\> `StockLocation` data model](#sales-channel-module).
+
+---
+
## Fulfillment Module
A fulfillment set can be conditioned to a specific stock location.
@@ -18,6 +37,140 @@ Medusa also defines a link between the `FulfillmentProvider` and `StockLocation`
![A diagram showcasing an example of how data models from the Fulfillment and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1728399492/Medusa%20Resources/fulfillment-provider-stock-location_b0mulo.jpg)
+### Retrieve with Query
+
+To retrieve the fulfillment sets of a stock location with [Query](!docs!/learn/fundamentals/module-links/query), pass `fulfillment_sets.*` in `fields`:
+
+
+
+To retrieve the fulfillment providers, pass `fulfillment_providers.*` in `fields`.
+
+
+
+
+
+
+```ts
+const { data: stockLocations } = await query.graph({
+ entity: "stock_location",
+ fields: [
+ "fulfillment_sets.*"
+ ]
+})
+
+// stockLocations.fulfillment_sets
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: stockLocations } = useQueryGraphStep({
+ entity: "stock_location",
+ fields: [
+ "fulfillment_sets.*"
+ ]
+})
+
+// stockLocations.fulfillment_sets
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the stock location of a fulfillment set, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.STOCK_LOCATION]: {
+ stock_location_id: "sloc_123",
+ },
+ [Modules.FULFILLMENT]: {
+ fulfillment_set_id: "fset_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.STOCK_LOCATION]: {
+ stock_location_id: "sloc_123",
+ },
+ [Modules.FULFILLMENT]: {
+ fulfillment_set_id: "fset_123",
+ },
+})
+```
+
+
+
+
+---
+
+## Inventory Module
+
+Medusa defines a read-only link between the `StockLocation` data model and the [Inventory Module](../../inventory/page.mdx)'s `InventoryLevel` data model. This means you can retrieve the details of a stock location's inventory levels, but you don't manage the links in a pivot table in the database. The stock location of an inventory level is determined by the `location_id` property of the `InventoryLevel` data model.
+
+### Retrieve with Query
+
+To retrieve the inventory levels of a stock location with [Query](!docs!/learn/fundamentals/module-links/query), pass `inventory_levels.*` in `fields`:
+
+
+
+
+```ts
+const { data: stockLocations } = await query.graph({
+ entity: "stock_location",
+ fields: [
+ "inventory_levels.*"
+ ]
+})
+
+// stockLocations.inventory_levels
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: stockLocations } = useQueryGraphStep({
+ entity: "stock_location",
+ fields: [
+ "inventory_levels.*"
+ ]
+})
+
+// stockLocations.inventory_levels
+```
+
+
+
+
---
## Sales Channel Module
@@ -27,3 +180,86 @@ A stock location is associated with a sales channel. This scopes inventory quant
Medusa defines a link between the `SalesChannel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Sales Channel and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716796872/Medusa%20Resources/sales-channel-location_cqrih1.jpg)
+
+### Retrieve with Query
+
+To retrieve the sales channels of a stock location with [Query](!docs!/learn/fundamentals/module-links/query), pass `sales_channels.*` in `fields`:
+
+
+
+
+```ts
+const { data: stockLocations } = await query.graph({
+ entity: "stock_location",
+ fields: [
+ "sales_channels.*"
+ ]
+})
+
+// stockLocations.sales_channels
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: stockLocations } = useQueryGraphStep({
+ entity: "stock_location",
+ fields: [
+ "sales_channels.*"
+ ]
+})
+
+// stockLocations.sales_channels
+```
+
+
+
+
+### Manage with Remote Link
+
+To manage the stock locations of a sales channel, use [Remote Link](!docs!/learn/fundamentals/module-links/remote-link):
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+
+// ...
+
+await remoteLink.create({
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+ [Modules.STOCK_LOCATION]: {
+ sales_channel_id: "sloc_123",
+ },
+})
+```
+
+
+
+
+```ts
+import { Modules } from "@medusajs/framework/utils"
+import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+createRemoteLinkStep({
+ [Modules.SALES_CHANNEL]: {
+ sales_channel_id: "sc_123",
+ },
+ [Modules.STOCK_LOCATION]: {
+ sales_channel_id: "sloc_123",
+ },
+})
+```
+
+
+
diff --git a/www/apps/resources/app/commerce-modules/store/links-to-other-modules/page.mdx b/www/apps/resources/app/commerce-modules/store/links-to-other-modules/page.mdx
new file mode 100644
index 0000000000000..a9710b966b2d5
--- /dev/null
+++ b/www/apps/resources/app/commerce-modules/store/links-to-other-modules/page.mdx
@@ -0,0 +1,68 @@
+import { CodeTabs, CodeTab } from "docs-ui"
+
+export const metadata = {
+ title: `Links between Store Module and Other Modules`,
+}
+
+# {metadata.title}
+
+This document showcases the module links defined between the Store Module and other commerce modules.
+
+## Summary
+
+The Store 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.
+
+
+
+- [`Currency` data model \<\> `Currency` data model of Currency Module](#currency-module). (Read-only).
+
+---
+
+## Currency Module
+
+The Store Module has a `Currency` data model that stores the supported currencies of a store. However, these currencies don't hold all the details of a currency, such as its name or symbol.
+
+Instead, Medusa defines a read-only link between the [Currency Module](../../currency/page.mdx)'s `Currency` data model and the Store Module's `Currency` data model. This means you can retrieve the details of a store's supported currencies, but you don't manage the links in a pivot table in the database. The currencies of a store are determined by the `currency_code` of the `Currency` data model in the Store Module.
+
+### Retrieve with Query
+
+To retrieve the details of a store's currencies with [Query](!docs!/learn/fundamentals/module-links/query), pass `supported_currencies.currency.*` in `fields`:
+
+
+
+
+```ts
+const { data: stores } = await query.graph({
+ entity: "store",
+ fields: [
+ "supported_currencies.currency.*"
+ ]
+})
+
+// stores.supported_currencies
+```
+
+
+
+
+```ts
+import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
+
+// ...
+
+const { data: stores } = useQueryGraphStep({
+ entity: "store",
+ fields: [
+ "supported_currencies.currency.*"
+ ]
+})
+
+// stores.supported_currencies
+```
+
+
+
diff --git a/www/apps/resources/generated/edit-dates.mjs b/www/apps/resources/generated/edit-dates.mjs
index 543900d7e0bf8..abca5cdb60fa6 100644
--- a/www/apps/resources/generated/edit-dates.mjs
+++ b/www/apps/resources/generated/edit-dates.mjs
@@ -2148,21 +2148,21 @@ export const generatedEditDates = {
"app/admin-components/components/forms/page.mdx": "2024-10-09T12:48:04.229Z",
"app/commerce-modules/auth/reset-password/page.mdx": "2024-11-27T13:33:55.940Z",
"app/storefront-development/customers/reset-password/page.mdx": "2024-12-19T16:32:00.724Z",
- "app/commerce-modules/api-key/links-to-other-modules/page.mdx": "2024-10-08T08:05:36.596Z",
+ "app/commerce-modules/api-key/links-to-other-modules/page.mdx": "2024-12-24T14:36:06.109Z",
"app/commerce-modules/cart/extend/page.mdx": "2024-12-11T09:05:37.041Z",
- "app/commerce-modules/cart/links-to-other-modules/page.mdx": "2024-10-08T08:22:35.190Z",
+ "app/commerce-modules/cart/links-to-other-modules/page.mdx": "2024-12-24T14:46:49.847Z",
"app/commerce-modules/customer/extend/page.mdx": "2024-12-16T14:11:47.517Z",
- "app/commerce-modules/fulfillment/links-to-other-modules/page.mdx": "2024-10-08T14:58:24.935Z",
- "app/commerce-modules/inventory/links-to-other-modules/page.mdx": "2024-10-08T15:18:30.109Z",
- "app/commerce-modules/pricing/links-to-other-modules/page.mdx": "2024-10-09T13:51:49.986Z",
+ "app/commerce-modules/fulfillment/links-to-other-modules/page.mdx": "2024-12-24T14:49:54.535Z",
+ "app/commerce-modules/inventory/links-to-other-modules/page.mdx": "2024-12-24T14:50:25.574Z",
+ "app/commerce-modules/pricing/links-to-other-modules/page.mdx": "2024-12-24T14:53:39.198Z",
"app/commerce-modules/product/extend/page.mdx": "2024-12-11T09:07:25.252Z",
- "app/commerce-modules/product/links-to-other-modules/page.mdx": "2024-10-09T14:14:09.401Z",
+ "app/commerce-modules/product/links-to-other-modules/page.mdx": "2024-12-24T14:55:21.779Z",
"app/commerce-modules/promotion/extend/page.mdx": "2024-12-11T09:07:24.137Z",
- "app/commerce-modules/promotion/links-to-other-modules/page.mdx": "2024-10-09T14:51:37.194Z",
+ "app/commerce-modules/promotion/links-to-other-modules/page.mdx": "2024-12-24T14:56:11.410Z",
"app/commerce-modules/order/edit/page.mdx": "2024-10-09T08:50:05.334Z",
- "app/commerce-modules/order/links-to-other-modules/page.mdx": "2024-10-09T11:23:05.488Z",
+ "app/commerce-modules/order/links-to-other-modules/page.mdx": "2024-12-24T14:52:22.813Z",
"app/commerce-modules/order/order-change/page.mdx": "2024-10-09T09:59:40.745Z",
- "app/commerce-modules/payment/links-to-other-modules/page.mdx": "2024-10-09T11:23:02.023Z",
+ "app/commerce-modules/payment/links-to-other-modules/page.mdx": "2024-12-24T14:53:08.217Z",
"references/core_flows/Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx": "2024-12-23T12:30:23.699Z",
"references/core_flows/Payment/Workflows_Payment/functions/core_flows.Payment.Workflows_Payment.processPaymentWorkflow/page.mdx": "2024-12-23T12:30:26.014Z",
"references/helper_steps/functions/helper_steps.useQueryGraphStep/page.mdx": "2024-12-10T14:55:09.191Z",
@@ -2211,10 +2211,10 @@ export const generatedEditDates = {
"references/fulfillment/interfaces/fulfillment.IFulfillmentModuleService/page.mdx": "2024-12-17T16:57:25.097Z",
"references/types/CommonTypes/interfaces/types.CommonTypes.RequestQueryFields/page.mdx": "2024-12-09T13:21:32.865Z",
"references/utils/utils.ProductUtils/page.mdx": "2024-12-10T14:54:57.156Z",
- "app/commerce-modules/region/links-to-other-modules/page.mdx": "2024-10-15T14:10:50.853Z",
- "app/commerce-modules/sales-channel/links-to-other-modules/page.mdx": "2024-10-15T14:25:29.097Z",
- "app/commerce-modules/stock-location/links-to-other-modules/page.mdx": "2024-10-15T14:33:11.483Z",
- "app/commerce-modules/store/links-to-other-modules/page.mdx": "2024-06-26T07:19:49.931Z",
+ "app/commerce-modules/region/links-to-other-modules/page.mdx": "2024-12-24T14:56:43.092Z",
+ "app/commerce-modules/sales-channel/links-to-other-modules/page.mdx": "2024-12-24T14:57:34.314Z",
+ "app/commerce-modules/stock-location/links-to-other-modules/page.mdx": "2024-12-24T14:58:09.715Z",
+ "app/commerce-modules/store/links-to-other-modules/page.mdx": "2024-12-24T14:58:24.038Z",
"app/examples/page.mdx": "2024-12-11T09:07:47.589Z",
"app/medusa-cli/commands/build/page.mdx": "2024-11-11T11:00:49.665Z",
"app/js-sdk/page.mdx": "2024-12-12T11:41:51.152Z",
@@ -5779,5 +5779,7 @@ export const generatedEditDates = {
"app/commerce-modules/stock-location/admin-widget-zones/page.mdx": "2024-12-24T08:38:38.403Z",
"app/commerce-modules/store/admin-widget-zones/page.mdx": "2024-12-24T08:46:28.646Z",
"app/commerce-modules/tax/admin-widget-zones/page.mdx": "2024-12-24T08:47:13.176Z",
- "app/commerce-modules/user/admin-widget-zones/page.mdx": "2024-12-24T08:48:14.186Z"
+ "app/commerce-modules/user/admin-widget-zones/page.mdx": "2024-12-24T08:48:14.186Z",
+ "app/commerce-modules/currency/links-to-other-modules/page.mdx": "2024-12-24T14:47:10.556Z",
+ "app/commerce-modules/customer/links-to-other-modules/page.mdx": "2024-12-24T14:48:54.689Z"
}
\ No newline at end of file
diff --git a/www/apps/resources/generated/files-map.mjs b/www/apps/resources/generated/files-map.mjs
index 7102e40c1f148..840f7219eb4db 100644
--- a/www/apps/resources/generated/files-map.mjs
+++ b/www/apps/resources/generated/files-map.mjs
@@ -231,6 +231,10 @@ export const filesMap = [
"filePath": "/www/apps/resources/app/commerce-modules/currency/examples/page.mdx",
"pathname": "/commerce-modules/currency/examples"
},
+ {
+ "filePath": "/www/apps/resources/app/commerce-modules/currency/links-to-other-modules/page.mdx",
+ "pathname": "/commerce-modules/currency/links-to-other-modules"
+ },
{
"filePath": "/www/apps/resources/app/commerce-modules/currency/page.mdx",
"pathname": "/commerce-modules/currency"
@@ -255,6 +259,10 @@ export const filesMap = [
"filePath": "/www/apps/resources/app/commerce-modules/customer/extend/page.mdx",
"pathname": "/commerce-modules/customer/extend"
},
+ {
+ "filePath": "/www/apps/resources/app/commerce-modules/customer/links-to-other-modules/page.mdx",
+ "pathname": "/commerce-modules/customer/links-to-other-modules"
+ },
{
"filePath": "/www/apps/resources/app/commerce-modules/customer/page.mdx",
"pathname": "/commerce-modules/customer"
@@ -591,6 +599,10 @@ export const filesMap = [
"filePath": "/www/apps/resources/app/commerce-modules/store/examples/page.mdx",
"pathname": "/commerce-modules/store/examples"
},
+ {
+ "filePath": "/www/apps/resources/app/commerce-modules/store/links-to-other-modules/page.mdx",
+ "pathname": "/commerce-modules/store/links-to-other-modules"
+ },
{
"filePath": "/www/apps/resources/app/commerce-modules/store/page.mdx",
"pathname": "/commerce-modules/store"
diff --git a/www/apps/resources/generated/sidebar.mjs b/www/apps/resources/generated/sidebar.mjs
index 78178f22751f6..1c6b6b6a9d27a 100644
--- a/www/apps/resources/generated/sidebar.mjs
+++ b/www/apps/resources/generated/sidebar.mjs
@@ -1324,6 +1324,22 @@ export const generatedSidebar = [
"title": "Examples",
"children": []
},
+ {
+ "loaded": true,
+ "isPathHref": true,
+ "type": "sub-category",
+ "title": "Concepts",
+ "children": [
+ {
+ "loaded": true,
+ "isPathHref": true,
+ "type": "link",
+ "path": "/commerce-modules/currency/links-to-other-modules",
+ "title": "Link to Modules",
+ "children": []
+ }
+ ]
+ },
{
"loaded": true,
"isPathHref": true,
@@ -1450,6 +1466,14 @@ export const generatedSidebar = [
"path": "/commerce-modules/customer/customer-accounts",
"title": "Customer Accounts",
"children": []
+ },
+ {
+ "loaded": true,
+ "isPathHref": true,
+ "type": "link",
+ "path": "/commerce-modules/customer/links-to-other-modules",
+ "title": "Link to Modules",
+ "children": []
}
]
},
@@ -7215,6 +7239,22 @@ export const generatedSidebar = [
"title": "Examples",
"children": []
},
+ {
+ "loaded": true,
+ "isPathHref": true,
+ "type": "sub-category",
+ "title": "Concepts",
+ "children": [
+ {
+ "loaded": true,
+ "isPathHref": true,
+ "type": "link",
+ "path": "/commerce-modules/store/links-to-other-modules",
+ "title": "Link to Modules",
+ "children": []
+ }
+ ]
+ },
{
"loaded": true,
"isPathHref": true,
diff --git a/www/apps/resources/sidebars/currency.mjs b/www/apps/resources/sidebars/currency.mjs
index e4f9c082bd583..57a53b2bc928e 100644
--- a/www/apps/resources/sidebars/currency.mjs
+++ b/www/apps/resources/sidebars/currency.mjs
@@ -15,6 +15,17 @@ export const currencySidebar = [
path: "/commerce-modules/currency/examples",
title: "Examples",
},
+ {
+ type: "sub-category",
+ title: "Concepts",
+ children: [
+ {
+ type: "link",
+ path: "/commerce-modules/currency/links-to-other-modules",
+ title: "Link to Modules",
+ },
+ ],
+ },
{
type: "sub-category",
title: "References",
diff --git a/www/apps/resources/sidebars/customer.mjs b/www/apps/resources/sidebars/customer.mjs
index 631c947e578cc..3f1d6ec450082 100644
--- a/www/apps/resources/sidebars/customer.mjs
+++ b/www/apps/resources/sidebars/customer.mjs
@@ -29,6 +29,11 @@ export const customerSidebar = [
path: "/commerce-modules/customer/customer-accounts",
title: "Customer Accounts",
},
+ {
+ type: "link",
+ path: "/commerce-modules/customer/links-to-other-modules",
+ title: "Link to Modules",
+ },
],
},
{
diff --git a/www/apps/resources/sidebars/store.mjs b/www/apps/resources/sidebars/store.mjs
index 985d6e1ff45d0..08d87591ba8f8 100644
--- a/www/apps/resources/sidebars/store.mjs
+++ b/www/apps/resources/sidebars/store.mjs
@@ -15,6 +15,17 @@ export const storeSidebar = [
path: "/commerce-modules/store/examples",
title: "Examples",
},
+ {
+ type: "sub-category",
+ title: "Concepts",
+ children: [
+ {
+ type: "link",
+ path: "/commerce-modules/store/links-to-other-modules",
+ title: "Link to Modules",
+ },
+ ],
+ },
{
type: "sub-category",
title: "References",