You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/admin/guides/order-management.md
+109Lines changed: 109 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ Order management operations can be automated through the Admin API for more effi
10
10
11
11
Below are best practices and guides for common scenarios merchants and partners use to manage orders on the Admin API.
12
12
13
+
14
+
13
15
### Order Refunds
14
16
15
17
Order management actions that require refunding and removing items from an order can be done through the refund flow. The refund flow is espcially useful when creating partial refunds or creating refunds for items that have already shipped to the customer.
@@ -150,6 +152,104 @@ Depending on the product type and status of the line items being refunded, there
150
152
- If fulfilled, restock_type must be `no_restock`.
151
153
:::
152
154
155
+
### Order Items Editing
156
+
157
+
Editing items on an order is common practice, such as swapping products purchased for a different size or color.
158
+
159
+
:::info Only Available on 2024-04-01 API Version
160
+
Order editing APIs are only available on 2024-04-01 API Version and above, if you are still using older versions we recommend you upgrade your integration.
161
+
162
+
Order editing APIs also do not affect order payment within each request. To remove items with an associated refund, see [order refunds](#order-refunds). Using order edit APIs can result in the customer owing or the merchant owing to the customer.
163
+
:::
164
+
165
+
#### Line Item Quantties Explained
166
+
167
+
Order line items have 4 quanity attributes that represent quantities at differen't states in an order life cycle.
168
+
169
+
-`quantity` - Item quantity of items ever added to the order in this line item.
170
+
-`current_quantity` - Current item quantity that have not yet been removed.
171
+
-`fulfillable_quantity` - Item quantity that have not yet been fulfilled, such as a partial fulfillment.
172
+
-`editable_quantity` - Item quantity that currently can be edited.
173
+
174
+
```json title="Line Item Qantities Explained"
175
+
"lines": [
176
+
{
177
+
...
178
+
"quantity": 3, // quantity of items ever added
179
+
"current_quantity": 2, // current quantity that have not been removed
180
+
"fulfillable_quantity": 1, // quantity that have not yet been fulfilled
181
+
"editable_quantity": 1, // quantity that can be edited
182
+
...
183
+
}
184
+
]
185
+
```
186
+
187
+
#### Swap Items Flow
188
+
189
+
190
+
```mermaid
191
+
stateDiagram-v2
192
+
direction LR
193
+
lines: Retrieve Order Lines
194
+
removeLine: Remove Unwanted Items
195
+
addLine: Add Line Item
196
+
lines --> removeLine
197
+
removeLine --> addLine
198
+
```
199
+
200
+
Swaping Items on an order is a 3-step process:
201
+
1. Retreive order line items using the [ordersRetrieve](/docs/api/admin/reference/?v=2024-04-01#/operations/ordersRetrieve) endpoint to obtain line items and check `editable_quantity` is > 0.
202
+
2. Update/Remove line items using the [ordersLinesPartialUpdate](/docs/api/admin/reference/?v=2024-04-01#/operations/ordersLinesPartialUpdate) or [ordersLinesDestroy](/docs/api/admin/reference/?v=2024-04-01#/operations/ordersLinesDestroy) endpoint.
203
+
3. Create new line item [ordersLinesCreate](/docs/api/admin/reference/?v=2024-04-01#/operations/ordersLinesCreate) endpoint.
204
+
205
+
206
+
#### Update Existing Line Item
207
+
208
+
Below is an example API call to change the quantity of a line item to 1. If the existing quantity was 2, this would remove 1 quantity, can also be used to increase line item quantity. This endpoint only accepts quantity changes, to change the product or price, see [ordersLinesCreate](/docs/api/admin/reference/?v=2024-04-01#/operations/ordersLinesCreate) endpoint.
Below is an example DELETE request to the [ordersLinesDestroy](/docs/api/admin/reference/?v=2024-04-01#/operations/ordersLinesDestroy) endpoint to remove a line item.
Line items have `editable_quantity` which represents the item quantity not already in process of being fulfilled, already fulfilled, or already removed from the order.
232
+
233
+
**If `editable_quantity` is `0`, the line item cannot be edited.**
234
+
:::
235
+
236
+
237
+
#### Create New Line Item
238
+
239
+
Below is an example POST request to the [ordersLinesCreate](/docs/api/admin/reference/?v=2024-04-01#/operations/ordersLinesCreate) endpoint to create a new line item.
240
+
241
+
```json title="Create New Line Item"
242
+
// POST https://{store}.29next.store/api/admin/orders/{number}/lines/
0 commit comments