Search code examples
wordpresswoocommercewoocommerce-rest-api

How does WooCommerce asssign a customer_id?


I'm building a WooCommerce site and plan to treat all customers as guests, meaning there's no reason to force them to create accounts. I interact with the system using the REST API to get information about each order.

Within an order there is a field called "customer_id". I assume that this value will be unique for each user but am finding that it isn't. How is this value assigned?

  • Cookie?
  • IP Address?
  • Hash of some customer data?

Additionally, I'm calling the API endpoint to get a list of customers and receiving an empty list. Is this because none of the users has created an account? Why don't I get information about the users who've bought products without registering?


Solution

  • Turns out they don't.

    Guest accounts always have a customer_id of 0.

    If I want to keep the customers straight I need to rely on different data such as the email.