SAP Open Connectors

Tips and FAQ

WooCommerce: Why Does GET /customers Return No Data?

If you have created customer and order data in your WooCommerce account and yet an API call to GET /customers returns an empty array then your problem may be with guest orders. When Guest Checkout is enabled and a guest order is created the customer_id will be recorded with a value of '0', which causes issues retrieving the customer data via API call.

In the WooCommerce documentation they actually call this out and recommend that you do NOT enable guest checkout for API integration business cases since customers must have an account for the WooCommerce API Manager to securely handle API requests. So in order to create valid WooCommerce data that can be retrieved through GET /customers do not create orders with guest checkout or with the Administrator role, and instead create orders using either the Customer or Subscriber roles.

https://docs.woocommerce.com/document/woocommerce-api-manager/

WooCommerce: What Fields Can Be Used For Query?

Querying against WooCommerce endpoints only accepts certain parameters, which are not fields in the vendor response body so it can be a little confusing to structure successful queries against WooCommerce. We are analyzing the possibility of normalizing query against the WooCommerce endpoints further, but for the time being the documented WooCommerce query syntax must be used.

For instance to query the /orders endpoint for a specific customer_id=1 the Where clause must be made like customer=1, and querying the /products endpoint for a specific product id=1651 must be made with a Where clause of include=1651.

WooCommerce has documented the available parameters for querying their endpoints including /orders and /products:

/orders available parameters: context, page, per_page, search, after, before, exclude, include, offset, order, orderby, parent, parent_exclude, status, customer, product, dp.

/products available parameters: context, page, per_page, search, after, before, exclude, include, offset, order, orderby, parent, parent_exclude, slug, status, type, sku, featured, category, tag, shipping_class, attribute, attribute_term, tax_class, in_stock, on_sale, min_price, max_price.