Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const wpapi = require('wpapi')
- let wp = new wpapi({
- endpoint: 'http://your.wp.site/wp-json/',
- username: 'user',
- password: 'pass',
- auth: true,
- routes: routes
- })
- let woo = wp.namespace('wc/v2')
- wp.users()
- .search('foo') // Search by (for example) username
- .param('context', 'edit') // Get additional fields
- .then(result => {
- let user = result[0]
- woo.customers().id(user.id) // Get WooCommerce specific fields
- .then(customer => {
- console.log('woo.customer', customer)
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement