Updates a product. See the docs
1
import WooCommerceRestApi from '@woocommerce/woocommerce-rest-api';
2
3
type WooCommerce = {
4
url: string;
5
consumerKey: string;
6
consumerSecret: string;
7
version?: string;
8
queryStringAuth?: boolean;
9
};
10
11
export async function main(resource: WooCommerce, productId: number, updatePayload: any) {
12
const WooCommerce = new WooCommerceRestApi(resource);
13
14
try {
15
const response = await WooCommerce.put(`products/${productId}`, updatePayload);
16
return response.data;
17
} catch (error) {
18
return {
19
error: true,
20
message: error.response.data || 'Internal Server Error',
21
}
22
23
24