Fulfill Order

Updates an order's status to fulfilled Required scope | `ecommerce:write`

Script webflow Verified

by hugo697 ยท 11/5/2024

The script

Submitted by hugo697 Bun
Verified 563 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: { sendOrderFulfilledEmail?: false | true }
11
) {
12
	const url = new URL(`https://api.webflow.com/v2/sites/${site_id}/orders/${order_id}/fulfill`)
13

14
	const response = await fetch(url, {
15
		method: 'POST',
16
		headers: {
17
			'Content-Type': 'application/json',
18
			Authorization: 'Bearer ' + auth.token
19
		},
20
		body: JSON.stringify(body)
21
	})
22

23
	if (!response.ok) {
24
		const text = await response.text()
25
		throw new Error(`${response.status} ${text}`)
26
	}
27

28
	return await response.json()
29
}
30