//native
type Webflow = {
token: string
}
export async function main(
auth: Webflow,
site_id: string,
product_id: string,
body: {
publishStatus?: 'staging' | 'live'
product?: {
id?: string
cmsLocaleId?: string
lastPublished?: string
lastUpdated?: string
createdOn?: string
isArchived?: false | true
isDraft?: false | true
fieldData?: {
name?: string
slug?: string
description?: string
shippable?: false | true
'sku-properties'?: {
id: string
name: string
enum: { id: string; name: string; slug: string }[]
}[]
categories?: string[]
'tax-category'?:
| 'standard-taxable'
| 'standard-exempt'
| 'books-religious'
| 'books-textbook'
| 'clothing'
| 'clothing-swimwear'
| 'digital-goods'
| 'digital-service'
| 'drugs-non-prescription'
| 'drugs-prescription'
| 'food-bottled-water'
| 'food-candy'
| 'food-groceries'
| 'food-prepared'
| 'food-soda'
| 'food-supplements'
| 'magazine-individual'
| 'magazine-subscription'
| 'service-admission'
| 'service-advertising'
| 'service-dry-cleaning'
| 'service-hairdressing'
| 'service-installation'
| 'service-miscellaneous'
| 'service-parking'
| 'service-printing'
| 'service-professional'
| 'service-repair'
| 'service-training'
'default-sku'?: string
'ec-product-type'?:
| 'ff42fee0113744f693a764e3431a9cc2'
| 'f22027db68002190aef89a4a2b7ac8a1'
| 'c599e43b1a1c34d5a323aedf75d3adf6'
| 'b6ccc1830db4b1babeb06a9ac5f6dd76'
}
}
sku?: {
id?: string
cmsLocaleId?: string
lastPublished?: string
lastUpdated?: string
createdOn?: string
fieldData?: {
'sku-values'?: {}
name: string
slug: string
price: { value?: number; unit?: string }
'compare-at-price'?: { value?: number; unit?: string }
'ec-sku-billing-method'?: 'one-time' | 'subscription'
'ec-sku-subscription-plan'?: {
interval?: 'day' | 'week' | 'month' | 'year'
frequency?: number
trial?: number
plans?: {
platform?: 'stripe'
id?: string
status?: 'active' | 'inactive' | 'canceled'
}[]
}
'track-inventory'?: false | true
quantity?: number
}
}
}
) {
const url = new URL(`https://api.webflow.com/v2/sites/${site_id}/products/${product_id}`)
const response = await fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + auth.token
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 253 days ago