|
1
|
--- |
|
2
|
products: |
|
3
|
- order |
|
4
|
- pricing |
|
5
|
- product |
|
6
|
- stock location |
|
7
|
--- |
|
8
|
|
|
9
|
import { CodeTabs, CodeTab, Table } from "docs-ui" |
|
10
|
|
|
11
|
export const metadata = { |
|
12
|
title: `Links between Fulfillment Module and Other Modules`, |
|
13
|
} |
|
14
|
|
|
15
|
# {metadata.title} |
|
16
|
|
|
17
|
This document showcases the module links defined between the Fulfillment Module and other Commerce Modules. |
|
18
|
|
|
19
|
## Summary |
|
20
|
|
|
21
|
The Fulfillment Module has the following links to other modules: |
|
22
|
|
|
23
|
<Table> |
|
24
|
<Table.Header> |
|
25
|
<Table.Row> |
|
26
|
<Table.HeaderCell> |
|
27
|
First Data Model |
|
28
|
</Table.HeaderCell> |
|
29
|
<Table.HeaderCell> |
|
30
|
Second Data Model |
|
31
|
</Table.HeaderCell> |
|
32
|
<Table.HeaderCell> |
|
33
|
Type |
|
34
|
</Table.HeaderCell> |
|
35
|
<Table.HeaderCell> |
|
36
|
Description |
|
37
|
</Table.HeaderCell> |
|
38
|
</Table.Row> |
|
39
|
</Table.Header> |
|
40
|
<Table.Body> |
|
41
|
<Table.Row> |
|
42
|
<Table.Cell> |
|
43
|
[ShippingMethod](/references/cart/models/ShippingMethod) in [Cart Module](../../cart/page.mdx) |
|
44
|
</Table.Cell> |
|
45
|
<Table.Cell> |
|
46
|
[ShippingOption](/references/fulfillment/models/ShippingOption) |
|
47
|
</Table.Cell> |
|
48
|
<Table.Cell> |
|
49
|
Read-only - has one |
|
50
|
</Table.Cell> |
|
51
|
<Table.Cell> |
|
52
|
[Learn more](#cart-module) |
|
53
|
</Table.Cell> |
|
54
|
</Table.Row> |
|
55
|
<Table.Row> |
|
56
|
<Table.Cell> |
|
57
|
[OrderShippingMethod](/references/order/models/OrderShippingMethod) in [Order Module](../../order/page.mdx) |
|
58
|
</Table.Cell> |
|
59
|
<Table.Cell> |
|
60
|
[ShippingOption](/references/fulfillment/models/ShippingOption) |
|
61
|
</Table.Cell> |
|
62
|
<Table.Cell> |
|
63
|
Read-only - has one |
|
64
|
</Table.Cell> |
|
65
|
<Table.Cell> |
|
66
|
[Learn more](#link-to-order-shipping-methods) |
|
67
|
</Table.Cell> |
|
68
|
</Table.Row> |
|
69
|
<Table.Row> |
|
70
|
<Table.Cell> |
|
71
|
[Order](/references/order/models/Order) in [Order Module](../../order/page.mdx) |
|
72
|
</Table.Cell> |
|
73
|
<Table.Cell> |
|
74
|
[Fulfillment](/references/fulfillment/models/Fulfillment) |
|
75
|
</Table.Cell> |
|
76
|
<Table.Cell> |
|
77
|
Stored - one-to-many |
|
78
|
</Table.Cell> |
|
79
|
<Table.Cell> |
|
80
|
[Learn more](#order-module) |
|
81
|
</Table.Cell> |
|
82
|
</Table.Row> |
|
83
|
<Table.Row> |
|
84
|
<Table.Cell> |
|
85
|
[Return](/references/order/models/Return) in [Order Module](../../order/page.mdx) |
|
86
|
</Table.Cell> |
|
87
|
<Table.Cell> |
|
88
|
[Fulfillment](/references/fulfillment/models/Fulfillment) |
|
89
|
</Table.Cell> |
|
90
|
<Table.Cell> |
|
91
|
Stored - one-to-many |
|
92
|
</Table.Cell> |
|
93
|
<Table.Cell> |
|
94
|
[Learn more](#order-module) |
|
95
|
</Table.Cell> |
|
96
|
</Table.Row> |
|
97
|
<Table.Row> |
|
98
|
<Table.Cell> |
|
99
|
[PriceSet](/references/pricing/models/PriceSet) in [Pricing Module](../../pricing/page.mdx) |
|
100
|
</Table.Cell> |
|
101
|
<Table.Cell> |
|
102
|
[ShippingOption](/references/fulfillment/models/ShippingOption) |
|
103
|
</Table.Cell> |
|
104
|
<Table.Cell> |
|
105
|
Stored - many-to-one |
|
106
|
</Table.Cell> |
|
107
|
<Table.Cell> |
|
108
|
[Learn more](#pricing-module) |
|
109
|
</Table.Cell> |
|
110
|
</Table.Row> |
|
111
|
<Table.Row> |
|
112
|
<Table.Cell> |
|
113
|
[Product](/references/product/models/Product) in [Product Module](../../product/page.mdx) |
|
114
|
</Table.Cell> |
|
115
|
<Table.Cell> |
|
116
|
[ShippingProfile](/references/fulfillment/models/ShippingProfile) |
|
117
|
</Table.Cell> |
|
118
|
<Table.Cell> |
|
119
|
Stored - many-to-one |
|
120
|
</Table.Cell> |
|
121
|
<Table.Cell> |
|
122
|
[Learn more](#product-module) |
|
123
|
</Table.Cell> |
|
124
|
</Table.Row> |
|
125
|
<Table.Row> |
|
126
|
<Table.Cell> |
|
127
|
[StockLocation](/references/stock-location-next/models/StockLocation) in [Stock Location Module](../../stock-location/page.mdx) |
|
128
|
</Table.Cell> |
|
129
|
<Table.Cell> |
|
130
|
[FulfillmentProvider](/references/fulfillment/models/FulfillmentProvider) |
|
131
|
</Table.Cell> |
|
132
|
<Table.Cell> |
|
133
|
Stored - one-to-many |
|
134
|
</Table.Cell> |
|
135
|
<Table.Cell> |
|
136
|
[Learn more](#stock-location-module) |
|
137
|
</Table.Cell> |
|
138
|
</Table.Row> |
|
139
|
<Table.Row> |
|
140
|
<Table.Cell> |
|
141
|
[StockLocation](/references/stock-location-next/models/StockLocation) in [Stock Location Module](../../stock-location/page.mdx) |
|
142
|
</Table.Cell> |
|
143
|
<Table.Cell> |
|
144
|
[FulfillmentSet](/references/fulfillment/models/FulfillmentSet) |
|
145
|
</Table.Cell> |
|
146
|
<Table.Cell> |
|
147
|
Stored - one-to-many |
|
148
|
</Table.Cell> |
|
149
|
<Table.Cell> |
|
150
|
[Learn more](#stock-location-module) |
|
151
|
</Table.Cell> |
|
152
|
</Table.Row> |
|
153
|
</Table.Body> |
|
154
|
</Table> |
|
155
|
|
|
156
|
--- |
|
157
|
|
|
158
|
## Cart Module |
|
159
|
|
|
160
|
Medusa defines a read-only link between the `ShippingMethod` data model of the [Cart Module](../../cart/page.mdx) and the `ShippingOption` data model. This means you can retrieve the details of a shipping method's shipping option, but you don't manage the links in a pivot table in the database. The shipping option of a shipping method is determined by the `shipping_option_id` property of the `ShippingMethod` data model. |
|
161
|
|
|
162
|
This link allows you to retrieve the shipping option that a shipping method was created from. |
|
163
|
|
|
164
|
<Note> |
|
165
|
|
|
166
|
This read-only link was added in [Medusa v2.10.0](https://github.com/medusajs/medusa/releases/tag/v2.10.0) |
|
167
|
|
|
168
|
</Note> |
|
169
|
|
|
170
|
### Retrieve with Query |
|
171
|
|
|
172
|
To retrieve the shipping option of a shipping method with [Query](!docs!/learn/fundamentals/query), pass `shipping_option.*` in `fields`: |
|
173
|
|
|
174
|
<CodeTabs group="relation-query"> |
|
175
|
<CodeTab label="query.graph" value="method"> |
|
176
|
|
|
177
|
```ts |
|
178
|
const { data: shippingMethods } = await query.graph({ |
|
179
|
entity: "shipping_method", |
|
180
|
fields: [ |
|
181
|
"shipping_option.*", |
|
182
|
], |
|
183
|
}) |
|
184
|
|
|
185
|
// shippingMethods[0].shipping_option |
|
186
|
``` |
|
187
|
|
|
188
|
</CodeTab> |
|
189
|
<CodeTab label="useQueryGraphStep" value="step"> |
|
190
|
|
|
191
|
```ts |
|
192
|
import { useQueryGraphStep } from "@medusajs/medusa/core-flows" |
|
193
|
|
|
194
|
// ... |
|
195
|
|
|
196
|
const { data: shippingMethods } = useQueryGraphStep({ |
|
197
|
entity: "shipping_method", |
|
198
|
fields: [ |
|
199
|
"shipping_option.*", |
|
200
|
], |
|
201
|
}) |
|
202
|
|
|
203
|
// shippingMethods[0].shipping_option |
|
204
|
``` |
|
205
|
|
|
206
|
</CodeTab> |
|
207
|
</CodeTabs> |
|
208
|
|
|
209
|
--- |
|
210
|
|
|
211
|
## Order Module |
|
212
|
|
|
213
|
### Link to Orders and Returns |
|
214
|
|
|
215
|
The [Order Module](../../order/page.mdx) provides order-management functionalities. |
|
216
|
|
|
217
|
Medusa defines a link between the `Fulfillment` and `Order` data models. A fulfillment is created for an orders' items. |
|
218
|
|
|
219
|
 |
|
220
|
|
|
221
|
A fulfillment is also created for a return's items. So, Medusa defines a link between the `Fulfillment` and `Return` data models. |
|
222
|
|
|
223
|
 |
|
224
|
|
|
225
|
#### Retrieve with Query |
|
226
|
|
|
227
|
To retrieve the order of a fulfillment with [Query](!docs!/learn/fundamentals/query), pass `order.*` in `fields`: |
|
228
|
|
|
229
|
<Note> |
|
230
|
|
|
231
|
To retrieve the return, pass `return.*` in `fields`. |
|
232
|
|
|
233
|
</Note> |
|
234
|
|
|
235
|
<CodeTabs group="relation-query"> |
|
236
|
<CodeTab label="query.graph" value="method"> |
|
237
|
|
|
238
|
```ts |
|
239
|
const { data: fulfillments } = await query.graph({ |
|
240
|
entity: "fulfillment", |
|
241
|
fields: [ |
|
242
|
"order.*", |
|
243
|
], |
|
244
|
}) |
|
245
|
|
|
246
|
// fulfillments.order |
|
247
|
``` |
|
248
|
|
|
249
|
</CodeTab> |
|
250
|
<CodeTab label="useQueryGraphStep" value="step"> |
|
251
|
|
|
252
|
```ts |
|
253
|
import { useQueryGraphStep } from "@medusajs/medusa/core-flows" |
|
254
|
|
|
255
|
// ... |
|
256
|
|
|
257
|
const { data: fulfillments } = useQueryGraphStep({ |
|
258
|
entity: "fulfillment", |
|
259
|
fields: [ |
|
260
|
"order.*", |
|
261
|
], |
|
262
|
}) |
|
263
|
|
|
264
|
// fulfillments.order |
|
265
|
``` |
|
266
|
|
|
267
|
</CodeTab> |
|
268
|
</CodeTabs> |
|
269
|
|
|
270
|
#### Manage with Link |
|
271
|
|
|
272
|
To manage the order of a cart, use [Link](!docs!/learn/fundamentals/module-links/link): |
|
273
|
|
|
274
|
<CodeTabs group="relation-link"> |
|
275
|
<CodeTab label="link.create" value="method"> |
|
276
|
|
|
277
|
```ts |
|
278
|
import { Modules } from "@medusajs/framework/utils" |
|
279
|
|
|
280
|
// ... |
|
281
|
|
|
282
|
await link.create({ |
|
283
|
[Modules.ORDER]: { |
|
284
|
order_id: "order_123", |
|
285
|
}, |
|
286
|
[Modules.FULFILLMENT]: { |
|
287
|
fulfillment_id: "ful_123", |
|
288
|
}, |
|
289
|
}) |
|
290
|
``` |
|
291
|
|
|
292
|
</CodeTab> |
|
293
|
<CodeTab label="createRemoteLinkStep" value="step"> |
|
294
|
|
|
295
|
```ts |
|
296
|
import { Modules } from "@medusajs/framework/utils" |
|
297
|
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows" |
|
298
|
|
|
299
|
// ... |
|
300
|
|
|
301
|
createRemoteLinkStep({ |
|
302
|
[Modules.ORDER]: { |
|
303
|
order_id: "order_123", |
|
304
|
}, |
|
305
|
[Modules.FULFILLMENT]: { |
|
306
|
fulfillment_id: "ful_123", |
|
307
|
}, |
|
308
|
}) |
|
309
|
``` |
|
310
|
|
|
311
|
</CodeTab> |
|
312
|
</CodeTabs> |
|
313
|
|
|
314
|
### Link to Order Shipping Methods |
|
315
|
|
|
316
|
Medusa defines a read-only link between the `OrderShippingMethod` data model of the [Order Module](../../order/page.mdx) and the `ShippingOption` data model. This means you can retrieve the details of an order shipping method's shipping option, but you don't manage the links in a pivot table in the database. The shipping option of an order shipping method is determined by the `shipping_option_id` property of the `OrderShippingMethod` data model. |
|
317
|
|
|
318
|
This link allows you to retrieve the shipping option that an order's shipping method was created from. |
|
319
|
|
|
320
|
<Note> |
|
321
|
|
|
322
|
This link is available since [Medusa v2.21.1](https://github.com/medusajs/medusa/releases/tag/v2.21.1). |
|
323
|
|
|
324
|
</Note> |
|
325
|
|
|
326
|
#### Retrieve with Query |
|
327
|
|
|
328
|
To retrieve the shipping option of an order shipping method with [Query](!docs!/learn/fundamentals/query), pass `shipping_option.*` in `fields`: |
|
329
|
|
|
330
|
<CodeTabs group="relation-query"> |
|
331
|
<CodeTab label="query.graph" value="method"> |
|
332
|
|
|
333
|
```ts |
|
334
|
const { data: orderShippingMethods } = await query.graph({ |
|
335
|
entity: "order_shipping_method", |
|
336
|
fields: [ |
|
337
|
"shipping_option.*", |
|
338
|
], |
|
339
|
}) |
|
340
|
|
|
341
|
// orderShippingMethods[0].shipping_option |
|
342
|
``` |
|
343
|
|
|
344
|
</CodeTab> |
|
345
|
<CodeTab label="useQueryGraphStep" value="step"> |
|
346
|
|
|
347
|
```ts |
|
348
|
import { useQueryGraphStep } from "@medusajs/medusa/core-flows" |
|
349
|
|
|
350
|
// ... |
|
351
|
|
|
352
|
const { data: orderShippingMethods } = useQueryGraphStep({ |
|
353
|
entity: "order_shipping_method", |
|
354
|
fields: [ |
|
355
|
"shipping_option.*", |
|
356
|
], |
|
357
|
}) |
|
358
|
|
|
359
|
// orderShippingMethods[0].shipping_option |
|
360
|
``` |
|
361
|
|
|
362
|
</CodeTab> |
|
363
|
</CodeTabs> |
|
364
|
|
|
365
|
--- |
|
366
|
|
|
367
|
## Pricing Module |
|
368
|
|
|
369
|
The Pricing Module provides features to store, manage, and retrieve the best prices in a specified context. |
|
370
|
|
|
371
|
Medusa defines a link between the `PriceSet` and `ShippingOption` data models. A shipping option's price is stored as a price set. |
|
372
|
|
|
373
|
 |
|
374
|
|
|
375
|
### Retrieve with Query |
|
376
|
|
|
377
|
To retrieve the price set of a shipping option with [Query](!docs!/learn/fundamentals/query), pass `price_set.*` in `fields`: |
|
378
|
|
|
379
|
<CodeTabs group="relation-query"> |
|
380
|
<CodeTab label="query.graph" value="method"> |
|
381
|
|
|
382
|
```ts |
|
383
|
const { data: shippingOptions } = await query.graph({ |
|
384
|
entity: "shipping_option", |
|
385
|
fields: [ |
|
386
|
"price_set_link.*", |
|
387
|
], |
|
388
|
}) |
|
389
|
|
|
390
|
// shippingOptions[0].price_set_link?.price_set_id |
|
391
|
``` |
|
392
|
|
|
393
|
</CodeTab> |
|
394
|
<CodeTab label="useQueryGraphStep" value="step"> |
|
395
|
|
|
396
|
```ts |
|
397
|
import { useQueryGraphStep } from "@medusajs/medusa/core-flows" |
|
398
|
|
|
399
|
// ... |
|
400
|
|
|
401
|
const { data: shippingOptions } = useQueryGraphStep({ |
|
402
|
entity: "shipping_option", |
|
403
|
fields: [ |
|
404
|
"price_set_link.*", |
|
405
|
], |
|
406
|
}) |
|
407
|
|
|
408
|
// shippingOptions[0].price_set_link?.price_set_id |
|
409
|
``` |
|
410
|
|
|
411
|
</CodeTab> |
|
412
|
</CodeTabs> |
|
413
|
|
|
414
|
### Manage with Link |
|
415
|
|
|
416
|
To manage the price set of a shipping option, use [Link](!docs!/learn/fundamentals/module-links/link): |
|
417
|
|
|
418
|
<CodeTabs group="relation-link"> |
|
419
|
<CodeTab label="link.create" value="method"> |
|
420
|
|
|
421
|
```ts |
|
422
|
import { Modules } from "@medusajs/framework/utils" |
|
423
|
|
|
424
|
// ... |
|
425
|
|
|
426
|
await link.create({ |
|
427
|
[Modules.FULFILLMENT]: { |
|
428
|
shipping_option_id: "so_123", |
|
429
|
}, |
|
430
|
[Modules.PRICING]: { |
|
431
|
price_set_id: "pset_123", |
|
432
|
}, |
|
433
|
}) |
|
434
|
``` |
|
435
|
|
|
436
|
</CodeTab> |
|
437
|
<CodeTab label="createRemoteLinkStep" value="step"> |
|
438
|
|
|
439
|
```ts |
|
440
|
import { Modules } from "@medusajs/framework/utils" |
|
441
|
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows" |
|
442
|
|
|
443
|
// ... |
|
444
|
|
|
445
|
createRemoteLinkStep({ |
|
446
|
[Modules.FULFILLMENT]: { |
|
447
|
shipping_option_id: "so_123", |
|
448
|
}, |
|
449
|
[Modules.PRICING]: { |
|
450
|
price_set_id: "pset_123", |
|
451
|
}, |
|
452
|
}) |
|
453
|
``` |
|
454
|
|
|
455
|
</CodeTab> |
|
456
|
</CodeTabs> |
|
457
|
|
|
458
|
--- |
|
459
|
|
|
460
|
## Product Module |
|
461
|
|
|
462
|
Medusa defines a link between the `ShippingProfile` data model and the `Product` data model of the Product Module. Each product must belong to a shipping profile. |
|
463
|
|
|
464
|
<Note> |
|
465
|
|
|
466
|
This link is introduced in [Medusa v2.5.0](https://github.com/medusajs/medusa/releases/tag/v2.5.0). |
|
467
|
|
|
468
|
</Note> |
|
469
|
|
|
470
|
### Retrieve with Query |
|
471
|
|
|
472
|
To retrieve the products of a shipping profile with [Query](!docs!/learn/fundamentals/query), pass `products.*` in `fields`: |
|
473
|
|
|
474
|
<CodeTabs group="relation-query"> |
|
475
|
<CodeTab label="query.graph" value="method"> |
|
476
|
|
|
477
|
```ts |
|
478
|
const { data: shippingProfiles } = await query.graph({ |
|
479
|
entity: "shipping_profile", |
|
480
|
fields: [ |
|
481
|
"products.*", |
|
482
|
], |
|
483
|
}) |
|
484
|
|
|
485
|
// shippingProfiles[0].products |
|
486
|
``` |
|
487
|
|
|
488
|
</CodeTab> |
|
489
|
<CodeTab label="useQueryGraphStep" value="step"> |
|
490
|
|
|
491
|
```ts |
|
492
|
import { useQueryGraphStep } from "@medusajs/medusa/core-flows" |
|
493
|
|
|
494
|
// ... |
|
495
|
|
|
496
|
const { data: shippingProfiles } = useQueryGraphStep({ |
|
497
|
entity: "shipping_profile", |
|
498
|
fields: [ |
|
499
|
"products.*", |
|
500
|
], |
|
501
|
}) |
|
502
|
|
|
503
|
// shippingProfiles[0].products |
|
504
|
``` |
|
505
|
|
|
506
|
</CodeTab> |
|
507
|
</CodeTabs> |
|
508
|
|
|
509
|
### Manage with Link |
|
510
|
|
|
511
|
To manage the shipping profile of a product, use [Link](!docs!/learn/fundamentals/module-links/link): |
|
512
|
|
|
513
|
<CodeTabs group="relation-link"> |
|
514
|
<CodeTab label="link.create" value="method"> |
|
515
|
|
|
516
|
```ts |
|
517
|
import { Modules } from "@medusajs/framework/utils" |
|
518
|
|
|
519
|
// ... |
|
520
|
|
|
521
|
await link.create({ |
|
522
|
[Modules.PRODUCT]: { |
|
523
|
product_id: "prod_123", |
|
524
|
}, |
|
525
|
[Modules.FULFILLMENT]: { |
|
526
|
shipping_profile_id: "sp_123", |
|
527
|
}, |
|
528
|
}) |
|
529
|
``` |
|
530
|
|
|
531
|
</CodeTab> |
|
532
|
<CodeTab label="createRemoteLinkStep" value="step"> |
|
533
|
|
|
534
|
```ts |
|
535
|
import { Modules } from "@medusajs/framework/utils" |
|
536
|
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows" |
|
537
|
|
|
538
|
// ... |
|
539
|
|
|
540
|
createRemoteLinkStep({ |
|
541
|
[Modules.PRODUCT]: { |
|
542
|
product_id: "prod_123", |
|
543
|
}, |
|
544
|
[Modules.FULFILLMENT]: { |
|
545
|
shipping_profile_id: "sp_123", |
|
546
|
}, |
|
547
|
}) |
|
548
|
``` |
|
549
|
|
|
550
|
</CodeTab> |
|
551
|
</CodeTabs> |
|
552
|
|
|
553
|
--- |
|
554
|
|
|
555
|
## Stock Location Module |
|
556
|
|
|
557
|
The Stock Location Module provides features to manage stock locations in a store. |
|
558
|
|
|
559
|
Medusa defines a link between the `FulfillmentSet` and `StockLocation` data models. A fulfillment set can be conditioned to a specific stock location. |
|
560
|
|
|
561
|
 |
|
562
|
|
|
563
|
Medusa also defines a link between the `FulfillmentProvider` and `StockLocation` data models to indicate the providers that can be used in a location. |
|
564
|
|
|
565
|
 |
|
566
|
|
|
567
|
### Retrieve with Query |
|
568
|
|
|
569
|
To retrieve the stock location of a fulfillment set with [Query](!docs!/learn/fundamentals/query), pass `location.*` in `fields`: |
|
570
|
|
|
571
|
<Note> |
|
572
|
|
|
573
|
To retrieve the stock location of a fulfillment provider, pass `locations.*` in `fields`. |
|
574
|
|
|
575
|
</Note> |
|
576
|
|
|
577
|
<CodeTabs group="relation-query"> |
|
578
|
<CodeTab label="query.graph" value="method"> |
|
579
|
|
|
580
|
```ts |
|
581
|
const { data: fulfillmentSets } = await query.graph({ |
|
582
|
entity: "fulfillment_set", |
|
583
|
fields: [ |
|
584
|
"location.*", |
|
585
|
], |
|
586
|
}) |
|
587
|
|
|
588
|
// fulfillmentSets[0].location |
|
589
|
``` |
|
590
|
|
|
591
|
</CodeTab> |
|
592
|
<CodeTab label="useQueryGraphStep" value="step"> |
|
593
|
|
|
594
|
```ts |
|
595
|
import { useQueryGraphStep } from "@medusajs/medusa/core-flows" |
|
596
|
|
|
597
|
// ... |
|
598
|
|
|
599
|
const { data: fulfillmentSets } = useQueryGraphStep({ |
|
600
|
entity: "fulfillment_set", |
|
601
|
fields: [ |
|
602
|
"location.*", |
|
603
|
], |
|
604
|
}) |
|
605
|
|
|
606
|
// fulfillmentSets[0].location |
|
607
|
``` |
|
608
|
|
|
609
|
</CodeTab> |
|
610
|
</CodeTabs> |
|
611
|
|
|
612
|
### Manage with Link |
|
613
|
|
|
614
|
To manage the stock location of a fulfillment set, use [Link](!docs!/learn/fundamentals/module-links/link): |
|
615
|
|
|
616
|
<CodeTabs group="relation-link"> |
|
617
|
<CodeTab label="link.create" value="method"> |
|
618
|
|
|
619
|
```ts |
|
620
|
import { Modules } from "@medusajs/framework/utils" |
|
621
|
|
|
622
|
// ... |
|
623
|
|
|
624
|
await link.create({ |
|
625
|
[Modules.STOCK_LOCATION]: { |
|
626
|
stock_location_id: "sloc_123", |
|
627
|
}, |
|
628
|
[Modules.FULFILLMENT]: { |
|
629
|
fulfillment_set_id: "fset_123", |
|
630
|
}, |
|
631
|
}) |
|
632
|
``` |
|
633
|
|
|
634
|
</CodeTab> |
|
635
|
<CodeTab label="createRemoteLinkStep" value="step"> |
|
636
|
|
|
637
|
```ts |
|
638
|
import { Modules } from "@medusajs/framework/utils" |
|
639
|
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows" |
|
640
|
|
|
641
|
// ... |
|
642
|
|
|
643
|
createRemoteLinkStep({ |
|
644
|
[Modules.STOCK_LOCATION]: { |
|
645
|
stock_location_id: "sloc_123", |
|
646
|
}, |
|
647
|
[Modules.FULFILLMENT]: { |
|
648
|
fulfillment_set_id: "fset_123", |
|
649
|
}, |
|
650
|
}) |
|
651
|
``` |
|
652
|
|
|
653
|
</CodeTab> |
|
654
|
</CodeTabs> |