forked from woocommerce/wc-api-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
43 lines (37 loc) · 1.23 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
var WooCommerceAPI = require('./index.js'); // use require('woocommerce-api')
// Initialize the WooCommerceAPI class
var WooCommerce = new WooCommerceAPI({
url: 'http://example.com', // Your store url (required)
// version: 'v3', // WooCommerce API version (optional)
// verifySsl: true, // Use `false` when need test with self-signed certificates, default is `true` (optional)
// encoding: 'utf8', // Encode, default is 'utf8' (optional)
consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', // Your API consumer key (required)
consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' // Your API consumer secret (required)
});
// GET example
WooCommerce.get('customers', function(err, data, res) {
console.log(res);
});
// POST example
// WooCommerce.post('products', {
// product: {
// title: 'Premium Quality',
// type: 'simple',
// regular_price: '21.99'
// }
// }, function(err, data, res) {
// console.log(res);
// });
// PUT example
// WooCommerce.put('orders/123', {
// order: {
// status: 'completed'
// }
// }, function(err, data, res) {
// console.log(res);
// });
// Delete example
// WooCommerce.delete('coupons/123', function(err, data, res) {
// console.log(res);
// });