I thought I’d share my solution for anyone working on a similar problem. I ended up switching to node-wpapi and using REST Autodiscovery to enable use of the WooCommerce & WordPress APIs from a single library. This can be done like so:
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')
Where routes
is a JSON representation of the REST API routes. See here for information on bootstrapping the API wrapper.
I’m then able to use both APIs side-by-side
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)
})
})
Related Posts:
- How to stop a Gutenberg Block from firing multiple GET Requests?
- Update a server-side render Block when woocommerce cart block changed
- List of JS events in the WooCommerce frontend
- WooCommerce: Can’t use wc_get_products for custom REST API endpoints
- Process checkout using WC REST API
- How to build a plugin that supports authenticated POST requests to the REST API from external servers?
- Extend Woocommerce rest api routes fails
- Hide Add to Cart Button
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- How to filter Post using Meta Data REST API
- Output JSON object with woocommerce products
- Problem with cURL and rest API
- Woo API REST : product variation price is read-only?
- “Cannot read property ‘replace’ of undefined” Javascript error when trying to add attribute terms from add product page [closed]
- Category Tree In WooCommerce Product API
- How to upload Woocommerce product images via API? [closed]
- Javascript / Ajax Error After Migrating To New Domain Name
- How can i stop woocommerce checkout event based on api request result?
- How to handle Woocommerce API credentials
- What will make Woocommerce REST API to issue 401 [closed]
- adding a script with type=”module” to woocommerce admin area
- Woocommerce custom endpoints
- Woocommerce REST API – updating an order changes custom tax calculations
- Force uppercase on some WooCommerce checkout fields input
- Woocommerce Rest Api Categories problem [closed]
- API returns blank response after installing & uninstalling WP-rest-api plugin
- woocommerce axios react
- Get specific values in Woocommerce Rest API
- Javascript error when adding an item to the cart [closed]
- wc_get_products() not return the images details
- WooCommerce – Add product with image via REST API
- Tax are not showing on order while placing order with REST API
- JWT on Woocommerce cannot work with “Customer” role user
- Woocommerce REST API – add filter to set maximum query per page for product brands [closed]
- WooCommerce – Create multiple product tags via rest api endpoint
- Add to cart – button should be disabled
- Retrieve Data from Custom Endpoint
- Woocommerce variable product’s total amount by javascript
- Ajax add to cart not updating Elementor mini cart totals
- Trying to run Javascript on AJAX call
- List of JS events in the WooCommerce frontend
- Woocommerce Checkout Page Total Price Inside Google Pay Script
- Running JavaScript after using WooCommerce Filter Plugin
- Deregister dequeue JS scripts except on 1 product page
- How to solve `Error getting remote image` in woocommerce rest api script?
- woocommerce deposit Form with AJAX and shortcode won’t update but add to previous output
- Getting in an exception for get product detail by id in woocommerce REST api
- How to make wocommerce shop products same heigt
- Impossible to create a new WooCommerce customer using Rest API
- Woocommerce API security concerns
- How can I send information when a order is completed to my own POS?
- Format number to 2 decimal places
- Woocommerce Rest API: woocommerce_product_invalid_image_id
- WC Booking query bookings with date ranges
- “error_message”: “Sorry, you cannot list resources.” using WooCommerce API
- currentURL is not defined
- Retrieve Woocommerce Cart Url with javascript/jquery [closed]
- Woocommerce REST API: creating variations
- Woocommerce REST API not considering discounts and coupons
- How to insert link, with lightbox, that opens specific page content only
- Woocommerce custom product with JS script, can’t understand how it works [closed]
- WooCommerce REST API endpoints don’t exist
- Removing ‘woocommerce-no-js’ class from body
- Fetch products with filter by similar categories at same time
- Send data to external websites when there is an update or create a post
- Auto generating API keys using the Application Authentication Endpoint [closed]
- GET woocommerce order request is not showing meta data [closed]
- How do I fix this “Uncaught ReferenceError: woodmartThemeModule is not defined”?
- Loading specific ajax from a product
- How to add fee_lines using woocommerce rest API v3?
- WooCommerce Order Sync via Custom REST API Endpoint Failing
- not saving the WC_Session_Handler session and removing the product from the cart session in WooCommerce’s custom rest api
- How to detect changes in WooCommerce store (react)?
- WooCommerce custom SVG coloring tool [closed]
- how do i remove a woo-commerce widget?
- Woocommerce – Shop page repeat the products with filters
- Create a shortcode for native WooCommerce search form [closed]
- Is there a preset CSS class when shopping cart isn’t empty?
- How can I convert woocommerce checkout fields in capital letters
- WC_Customer delete function returns error
- How to translate text in function.php with WPML [closed]
- Woocommerce product options [closed]
- WordPress SMS API integration without plugin error
- Allow only 1 quantity of particular product in cart WooCommerce
- Hide price and add to cart button on product page only
- How to make a custom button that redirects to a “user specified link while entering product details” woocommerce
- add sub subpage endpoint to woocommerce plugin my-account section
- Can’t find a product by SKU
- Woocommerce redirect “add to cart” button to a contact form with product information to get a inquiry
- add to cart button not adding products in cart only in safari and edge browser [closed]
- main menu hide woo commerce single products tittle
- Return ‘X-WP-Total’ from headers in response
- Weird strange letters appeared in all website links [duplicate]
- Absolute search against wordpress api
- Is it possible to remove editor from a custom product type?
- WC Lightbox, Zoom and Slider not loading [closed]
- How to remove WooCommerce Plugin some specific features [closed]
- Show Content On below single product with specific category
- What Hook/Action is performed when a field in checkout form is changed in WooCommerce
- Woocommerce – auto logout after payment