Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. const wpapi = require('wpapi')
  2.  
  3. let wp = new wpapi({
  4. endpoint: 'http://your.wp.site/wp-json/',
  5. username: 'user',
  6. password: 'pass',
  7. auth: true,
  8. routes: routes
  9. })
  10. let woo = wp.namespace('wc/v2')
  11.  
  12. wp.users()
  13. .search('foo') // Search by (for example) username
  14. .param('context', 'edit') // Get additional fields
  15. .then(result => {
  16. let user = result[0]
  17. woo.customers().id(user.id) // Get WooCommerce specific fields
  18. .then(customer => {
  19. console.log('woo.customer', customer)
  20. })
  21. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement