Edit an existing order with the Admin API
Apps can edit any order created by a Shopbase channel (for example, POS, online store, or draft orders) or any orders the app created through the API.
This guide explains how to use the Admin API to edit an existing order. For example, you might add new items to a customer’s order or alter the quantity of line items.

Types of edits to an order

You can make the following edits to an order:
  • Adjust quantity of a line item
  • Add new custom line items
  • Delete an order
  • Cancel an order
  • Open-Close a closed order

Access scopes

To use the Admin API to edit orders, your app needs to request the write_order_edits access scope for a Shopbase store. For more information on requesting access scopes when your app is installed, see OAuth.

Begin order editing

Retrieves a specific order

In Manage orders with the Rest Admin API, we learned how to create a new order and get its ID for future use. If you need to retrieve all the information related to a specific order, then do the following steps
Step 1: Send a GET method to this request URL
We have already learned how to get your API credential in the test and debug post.
Step 2: Save the request method for later use with Postman:
Step 3: Get the first line item's id properties for later adjustment.
1
let response = pm.response.json()
2
if (response.order.line_items[0].length > 0) pm.globals.set("line_item_id", response.order.line_items[0].id)
Copied!

Adjust quantity of a line item.

You can adjust the quantity of a line item to an order by passing the item id:
PUT https://shop-name.onshopbase.com/admin/orders/{order_id}/adjust.json
SAMPLE
1
{
2
"is_send_email": true,
3
"line_items": [
4
{ "id": {{line_item_id}},
5
"name": "New Item",
6
"properties": "Color",
7
"quantity": 15,
8
"require_shipping": true,
9
"restock": true,
10
"variant_id": 0
11
}
12
],
13
"reason": "Need more quantity"
14
}
Copied!
See the request in action with Postman:
1
let response = pm.response.json()
2
3
if (response.order.line_items[0].length > 0) {
4
pm.globals.set("line_item_id", response.order.line_items[0].id)
5
}
Copied!
It is always beneficial to save the request in the same collection we have been using for later use.

Add new custom line items

You can adjust the quantity of a line item to an order by passing:
PUT https://shop-name.onshopbase.com/admin/orders/{order_id}/adjust.json
SAMPLE
1
{
2
"is_send_email": true,
3
"line_items": [
4
{
5
"id": 0,
6
"is_custom": true,
7
"name": "string",
8
"price": 20,
9
"properties": "string",
10
"quantity": 10,
11
"require_shipping": true,
12
"restock": true,
13
"variant_id": 0
14
}
15
],
16
"reason": "We need more item"
17
}
Copied!
To create a new line item without modifying a pre-existed one, set the line item's id and variant's id to zero.

Delete an order

Deleting an order is truly simple. You can remove an existing order by passing:
DELETE https://shop-name.onshopbase.com/admin/orders/{order_id}.json

Cancel an order

POST https://shop-name.onshopbase.com/admin/orders/{order_id}/cancel.json
SAMPLE
1
{
2
"amount": "20",
3
"currency": "USD",
4
"email": true,
5
"reason": "customer",
6
"refund": {},
7
"restock": true
8
}
Copied!
Make sure you already has a set payment method before cancelling the order. For instruction on creating a payment method using Shopbase Api, read here

Open-Close a closed order

To open or close an order, pass the following POST method:
POST
1
https://shop-name.onshopbase.com/admin/orders/{order_id}/open.json
Copied!
Last modified 11mo ago