Update Order
One script reply has been approved by the moderators Verified

This API lets you update the fields, comment, shippingProvider, and/or shippingTracking for a given order. All three fields can be updated simultaneously or independently.

Required scope | ecommerce:write

Created by hugo697 514 days ago
Submitted by hugo697 Bun
Verified 514 days ago
1
//native
2
type Webflow = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Webflow,
8
	site_id: string,
9
	order_id: string,
10
	body: {
11
		comment?: string
12
		shippingProvider?: string
13
		shippingTracking?: string
14
		shippingTrackingURL?: string
15
	}
16
) {
17
	const url = new URL(`https://api.webflow.com/v2/sites/${site_id}/orders/${order_id}`)
18

19
	const response = await fetch(url, {
20
		method: 'PATCH',
21
		headers: {
22
			'Content-Type': 'application/json',
23
			Authorization: 'Bearer ' + auth.token
24
		},
25
		body: JSON.stringify(body)
26
	})
27

28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32

33
	return await response.json()
34
}
35