1 import { Table } from "docs-ui"
2
3 export const metadata = {
4 title: `Order Change`,
5 }
6
7 # {metadata.title}
8
9
10 In this document, you'll learn what an order change is and the related concepts.
11
12 ## OrderChange Data Model
13
14 The [OrderChange data model](/references/order/models/OrderChange) represents any kind of change to an order, such as a [return](../return/page.mdx), [exchange](../exchange/page.mdx), or [edit](../edit/page.mdx). Each of these is essentially an order change that is confirmed to apply changes to the original order.
15
16 The `OrderChange` model's `change_type` property indicates the purpose of the order change:
17
18 1. `edit`: The order change is making edits to the order, as explained in the [Order Edit](../edit/page.mdx) guide.
19 2. `exchange`: The order change is associated with an exchange, which you can learn about in the [Order Exchange](../exchange/page.mdx) guide.
20 3. `claim`: The order change is associated with a claim, which you can learn about in the [Order Claim](../claim/page.mdx) guide.
21 4. `return_request` or `return_receive`: The order change is associated with a return, which you can learn about in the [Order Return](../return/page.mdx) guide.
22
23 Once the order change is confirmed, its changes are applied to the order.
24
25 ---
26
27 ## Order Change Actions
28
29 The actions performed on the original order by an order change, such as adding an item, are represented by the [OrderChangeAction data model](/references/order/models/OrderChangeAction).
30
31 The `OrderChangeAction` has an `action` property that indicates the type of action to perform on the order, and a `details` property that holds additional information related to the action.
32
33 The following table lists the possible `action` values that Medusa uses and the corresponding `details` they carry.
34
35 <Table>
36 <Table.Header>
37 <Table.Row>
38 <Table.HeaderCell>
39 Action
40 </Table.HeaderCell>
41 <Table.HeaderCell>
42 Description
43 </Table.HeaderCell>
44 <Table.HeaderCell className="w-2/4">
45 Details
46 </Table.HeaderCell>
47 </Table.Row>
48 </Table.Header>
49 <Table.Body>
50 <Table.Row>
51 <Table.Cell>
52
53 `ITEM_ADD`
54
55 </Table.Cell>
56 <Table.Cell>
57
58 Add an item to the order. The item is only added after the change is confirmed.
59
60 </Table.Cell>
61 <Table.Cell>
62
63 `details` is an object having the following properties:
64
65 - `reference_id`: the ID of the new item.
66 - `quantity`: The item's quantity.
67 - `unit_price`: The item's unit price.
68 - `metadata`: The item's metadata.
69
70 </Table.Cell>
71 </Table.Row>
72 <Table.Row>
73 <Table.Cell>
74
75 `ITEM_UPDATE`
76
77 </Table.Cell>
78 <Table.Cell>
79
80 Update an item in an order change. It's only applied to the order after the change is confirmed.
81
82 </Table.Cell>
83 <Table.Cell>
84
85 `details` is an object having the following properties:
86
87 - `reference_id`: the ID of the item.
88 - `quantity`: The item's quantity.
89 - `unit_price`: The item's unit price.
90
91 </Table.Cell>
92 </Table.Row>
93 <Table.Row>
94 <Table.Cell>
95
96 `ITEM_REMOVE`
97
98 </Table.Cell>
99 <Table.Cell>
100
101 Remove an item from an order change. This can happen when a claim or an exchange is canceled.
102
103 </Table.Cell>
104 <Table.Cell>
105
106 `details` is an object having the following properties:
107
108 - `reference_id`: the ID of the item.
109 - `quantity`: The quantity to remove.
110
111 </Table.Cell>
112 </Table.Row>
113 <Table.Row>
114 <Table.Cell>
115
116 `RETURN_ITEM`
117
118 </Table.Cell>
119 <Table.Cell>
120
121 Set an item to be returned.
122
123 </Table.Cell>
124 <Table.Cell>
125
126 `details` is an object having the following properties:
127
128 - `reference_id`: the ID of the item.
129 - `quantity`: The quantity to be returned.
130 - `metadata`: The item's metadata.
131
132 </Table.Cell>
133 </Table.Row>
134 <Table.Row>
135 <Table.Cell>
136
137 `RECEIVE_RETURN_ITEM`
138
139 </Table.Cell>
140 <Table.Cell>
141
142 Mark a return item as received.
143
144 </Table.Cell>
145 <Table.Cell>
146
147 `details` is an object having the following properties:
148
149 - `reference_id`: the ID of the item.
150 - `quantity`: The quantity received. This quantity is added to the inventory quantity of the item's variant when the return is confirmed.
151
152 </Table.Cell>
153 </Table.Row>
154 <Table.Row>
155 <Table.Cell>
156
157 `RECEIVE_DAMAGED_RETURN_ITEM`
158
159 </Table.Cell>
160 <Table.Cell>
161
162 Mark a return item that's damaged as received.
163
164 </Table.Cell>
165 <Table.Cell>
166
167 `details` is an object having the following properties:
168
169 - `reference_id`: the ID of the item.
170 - `quantity`: The quantity received. This quantity isn't added to the item variant's inventory quantity, as the quantity is damaged.
171
172 </Table.Cell>
173 </Table.Row>
174 <Table.Row>
175 <Table.Cell>
176
177 `CANCEL_RETURN_ITEM`
178
179 </Table.Cell>
180 <Table.Cell>
181
182 Cancel the return of an item. This can happen when a return is canceled.
183
184 </Table.Cell>
185 <Table.Cell>
186
187 `details` is an object having the following properties:
188
189 - `reference_id`: the ID of the item.
190 - `quantity`: The quantity to cancel.
191
192 </Table.Cell>
193 </Table.Row>
194 <Table.Row>
195 <Table.Cell>
196
197 `SHIPPING_ADD`
198
199 </Table.Cell>
200 <Table.Cell>
201
202 Add a shipping method to an order change. It's only added to the order after the change is confirmed.
203
204 </Table.Cell>
205 <Table.Cell>
206
207 No details added. The ID to the shipping method is added in the `reference_id` property of the action.
208
209 </Table.Cell>
210 </Table.Row>
211 <Table.Row>
212 <Table.Cell>
213
214 `SHIPPING_REMOVE`
215
216 </Table.Cell>
217 <Table.Cell>
218
219 Remove a shipping method from an order change. This can happen when a claim or an exchange is canceled.
220
221 </Table.Cell>
222 <Table.Cell>
223
224 No details added. The ID to the shipping method is added in the `reference_id` property of the action.
225
226 </Table.Cell>
227 </Table.Row>
228 <Table.Row>
229 <Table.Cell>
230
231 `SHIP_ITEM`
232
233 </Table.Cell>
234 <Table.Cell>
235
236 Mark an item's quantity as shipped.
237
238 </Table.Cell>
239 <Table.Cell>
240
241 `details` is an object having the following properties:
242
243 - `reference_id`: the ID of the item.
244 - `quantity`: The quantity to mark as shipped.
245 - `metadata`: The item's metadata.
246
247 </Table.Cell>
248 </Table.Row>
249 <Table.Row>
250 <Table.Cell>
251
252 `FULFILL_ITEM`
253
254 </Table.Cell>
255 <Table.Cell>
256
257 Fulfill an item's quantity as part of a change.
258
259 </Table.Cell>
260 <Table.Cell>
261
262 `details` is an object having the following properties:
263
264 - `reference_id`: the ID of the item.
265 - `quantity`: The quantity to fulfill.
266 - `metadata`: The item's metadata.
267
268 </Table.Cell>
269 </Table.Row>
270 <Table.Row>
271 <Table.Cell>
272
273 `DELIVER_ITEM`
274
275 </Table.Cell>
276 <Table.Cell>
277
278 Mark an item's quantity as delivered.
279
280 </Table.Cell>
281 <Table.Cell>
282
283 `details` is an object having the following properties:
284
285 - `reference_id`: the ID of the item.
286 - `quantity`: The quantity to mark as delivered.
287 - `metadata`: The item's metadata.
288
289 </Table.Cell>
290 </Table.Row>
291 <Table.Row>
292 <Table.Cell>
293
294 `WRITE_OFF_ITEM`
295
296 </Table.Cell>
297 <Table.Cell>
298
299 Remove an item's quantity from an order change, without adding the quantity back to the item variant's inventory. The quantity isn't removed from the order until the change is confirmed.
300
301 </Table.Cell>
302 <Table.Cell>
303
304 `details` is an object having the following properties:
305
306 - `reference_id`: the ID of the item.
307 - `quantity`: The quantity to write off.
308 - `metadata`: The item's metadata.
309
310 </Table.Cell>
311 </Table.Row>
312 <Table.Row>
313 <Table.Cell>
314
315 `REINSTATE_ITEM`
316
317 </Table.Cell>
318 <Table.Cell>
319
320 Reinstate an item's quantity in an order change that was previously written off. The quantity is added back to the item variant's inventory when the change is confirmed.
321
322 </Table.Cell>
323 <Table.Cell>
324
325 `details` is an object having the following properties:
326
327 - `reference_id`: the ID of the item.
328 - `quantity`: The quantity to reinstate.
329
330 </Table.Cell>
331 </Table.Row>
332 <Table.Row>
333 <Table.Cell>
334
335 `TRANSFER_CUSTOMER`
336
337 </Table.Cell>
338 <Table.Cell>
339
340 Transfer an order to another customer. The order is not removed from the original customer until the change is confirmed.
341
342 </Table.Cell>
343 <Table.Cell>
344
345 No details added. The ID to the new customer is added in the `reference_id` property of the action.
346
347 </Table.Cell>
348 </Table.Row>
349 <Table.Row>
350 <Table.Cell>
351
352 `UPDATE_ORDER_PROPERTIES`
353
354 </Table.Cell>
355 <Table.Cell>
356
357 Update the properties of an order, such as customer information or shipping address. The properties are not updated on the original order until the change is confirmed.
358
359 </Table.Cell>
360 <Table.Cell>
361
362 `details` is an object that has the properties to update. The properties are the same as the ones in the [Order data model](/references/order/models/Order).
363
364 </Table.Cell>
365 </Table.Row>
366 <Table.Row>
367 <Table.Cell>
368
369 `PROMOTION_ADD`
370
371 </Table.Cell>
372 <Table.Cell>
373
374 Add a promotion to an order. The promotion is not added to the original order until the change is confirmed.
375
376 </Table.Cell>
377 <Table.Cell>
378
379 No details added. The ID to the promotion is added in the `reference_id` property of the action.
380
381 </Table.Cell>
382 </Table.Row>
383 <Table.Row>
384 <Table.Cell>
385
386 `PROMOTION_REMOVE`
387
388 </Table.Cell>
389 <Table.Cell>
390
391 Remove a promotion from an order. The promotion is not removed from the original order until the change is confirmed.
392
393 </Table.Cell>
394 <Table.Cell>
395
396 No details added. The ID to the promotion is added in the `reference_id` property of the action.
397
398 </Table.Cell>
399 </Table.Row>
400 <Table.Row>
401 <Table.Cell>
402
403 `ITEM_ADJUSTMENTS_REPLACE`
404
405 </Table.Cell>
406 <Table.Cell>
407
408 Replace item adjustments with new adjustments. The adjustments are not updated on the original order until the change is confirmed.
409
410 </Table.Cell>
411 <Table.Cell>
412
413 `details` is an object containing the new adjustment data:
414
415 - `reference_id`: the ID of the item.
416 - `adjustments`: an array of adjustments to apply to the item. Each adjustment is an object having the following properties:
417 - `code`: the promotion code that generated the adjustment, if applicable.
418 - `amount`: the adjustment amount.
419 - `item_id`: the ID of the item to apply the adjustment to.
420 - `promotion_id`: the ID of the promotion that generated the adjustment, if applicable.
421
422 </Table.Cell>
423 </Table.Row>
424 <Table.Row>
425 <Table.Cell>
426
427 `SHIPPING_ADJUSTMENTS_REPLACE` (v2.14.0+)
428
429 </Table.Cell>
430 <Table.Cell>
431
432 Replace shipping method adjustments with new adjustments. The adjustments are not updated on the original order until the change is confirmed.
433
434 </Table.Cell>
435 <Table.Cell>
436
437 `details` is an object containing the new adjustment data:
438
439 - `reference_id`: the ID of the shipping method.
440 - `adjustments`: an array of adjustments to apply to the shipping method. Each adjustment is an object having the following properties:
441 - `code`: the promotion code that generated the adjustment, if applicable.
442 - `amount`: the adjustment amount.
443 - `shipping_method_id`: the ID of the shipping method to apply the adjustment to.
444 - `promotion_id`: the ID of the promotion that generated the adjustment, if applicable.
445
446 </Table.Cell>
447 </Table.Row>
448 <Table.Row>
449 <Table.Cell>
450
451 `CREDIT_LINE_ADD`
452
453 </Table.Cell>
454 <Table.Cell>
455
456 Add a credit line to an order. The credit line is not added to the original order until the change is confirmed.
457
458 </Table.Cell>
459 <Table.Cell>
460
461 No details added. The ID to the associated payment is added in the `reference_id` property of the action.
462
463 </Table.Cell>
464 </Table.Row>
465 </Table.Body>
466 </Table>