Skip to content

Commit d323abf

Browse files
committed
add order editing to order mgmt guide
1 parent 4313a19 commit d323abf

1 file changed

Lines changed: 109 additions & 0 deletions

File tree

docs/api/admin/guides/order-management.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Order management operations can be automated through the Admin API for more effi
1010

1111
Below are best practices and guides for common scenarios merchants and partners use to manage orders on the Admin API.
1212

13+
14+
1315
### Order Refunds
1416

1517
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
150152
- If fulfilled, restock_type must be `no_restock`.
151153
:::
152154

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.
209+
210+
```json title="Update Existing Line Item"
211+
// PATCH https://{store}.29next.store/api/admin/orders/{number}/lines/{lineID}/
212+
// -H "Authorization: Bearer <API ACCESS TOKEN>" -H "X-29Next-Api-Version: 2024-04-01"
213+
214+
{
215+
"quantity": 1, // change quantity to 1
216+
"reason": "product swap" // optional
217+
}
218+
```
219+
220+
#### Remove Full Line Item
221+
222+
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.
223+
224+
```json title="Remove Line Item"
225+
// DELETE https://{store}.29next.store/api/admin/orders/{number}/lines/{lineID}/
226+
// -H "Authorization: Bearer <API ACCESS TOKEN>" -H "X-29Next-Api-Version: 2024-04-01"
227+
```
228+
229+
230+
:::info Check Line Item Editable Quantity
231+
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/
243+
// -H "Authorization: Bearer <API ACCESS TOKEN>" -H "X-29Next-Api-Version: 2024-04-01"
244+
245+
{
246+
"product_id": 184,
247+
"quantity": 1,
248+
"price": 89.99, // optional
249+
"reason": "product swap" // optional
250+
}
251+
```
252+
153253

154254
### Update Shipping Address
155255

@@ -158,6 +258,8 @@ Updating an order shipping address is a common task that can be done with a PATC
158258

159259
```json title="Update Order Shipping Address"
160260
// PATCH https://{store}.29next.store/api/admin/orders/{number}/
261+
// -H "Authorization: Bearer <API ACCESS TOKEN>" -H "X-29Next-Api-Version: 2024-04-01"
262+
161263
{
162264
"shipping_address": {
163265
"line1": "4765 Test Lane West", // new shipping adddress line 1
@@ -181,6 +283,7 @@ Fulfillment can be requested immediately through the [fulfillmentRequestSend](/d
181283

182284
```json title="Fulfillment Request"
183285
// POST https://{store}.29next.store/api/admin/fulfillment-orders/{id}/fulfillment-request/
286+
// -H "Authorization: Bearer <API ACCESS TOKEN>" -H "X-29Next-Api-Version: 2024-04-01"
184287

185288
{
186289
"fulfillment_order_line_items": [ // will split the fulfillment order into a new fulfillment order
@@ -210,6 +313,8 @@ stateDiagram-v2
210313

211314
```json title="Hold Fulfillment Order Request"
212315
// POST https://{store}.29next.store/api/admin/fulfillment-orders/{id}/hold/
316+
// -H "Authorization: Bearer <API ACCESS TOKEN>" -H "X-29Next-Api-Version: 2024-04-01"
317+
213318
{
214319
"reason": "address_incorrect", // see available reasons in api reference
215320
"reason_message": "Additional relevant detail." // provide additional relevant detail
@@ -234,6 +339,8 @@ stateDiagram-v2
234339

235340
```json titl="Fulfillment Order Cancellation Request"
236341
// POST https://{store}.29next.store/api/admin/fulfillment-orders/{id}/cancellation-request/
342+
// -H "Authorization: Bearer <API ACCESS TOKEN>" -H "X-29Next-Api-Version: 2024-04-01"
343+
237344
{
238345
"message": "Reason why canceling fulfillment" // message sent to the fulfillment location regarding the cancellation
239346
}
@@ -254,6 +361,8 @@ Canceling an order is a common order management task when you need to cancel the
254361

255362
```json title="Cacenl Order Request"
256363
// POST https://{store}.29next.store/api/admin/orders/{number}/cancel/
364+
// -H "Authorization: Bearer <API ACCESS TOKEN>" -H "X-29Next-Api-Version: 2024-04-01"
365+
257366
{
258367
"cancel_reason": "Customer wants to cancel", // Appropiate cancel reason message
259368
"full_refund": true, // Refund all remainaing payments or not

0 commit comments

Comments
 (0)