Customers
Retrieve and modify customers.
Table Specific Information
Select
WooCommerce allows only a small subset of columns to be used in the WHERE clause of a SELECT query. Following columns are supported server side, all other columns are processed client side.
- Id supports the '=,IN,NOT IN' operators.
- Email supports the '=' operator.
- Role supports the '=' operator.
SELECT * FROM Customers WHERE Id = 4 SELECT * FROM Customers WHERE Id IN (4,5) SELECT * FROM Customers WHERE Email = '[email protected]' SELECT * FROM Customers WHERE Username = 'user' AND IsPayingCustomer = true
By default, the following query returns the results for Role = All.
SELECT * FROM Customers;
Update
To introduce new metadata fields which are not present in the schema, the 'MetaDataAggregate' column can be used.
The update below will create two new metadata fields with keys 'key1' and 'key2' and set their respective values.
If any of the keys specified already exists, its value will be updated.
UPDATE Customers SET MetaDataAggregate = 'key1:val1, key2:val2' WHERE ID = 58
Insert
The following attribute is required when performing an insert: Email.
INSERT INTO Customers (Email) VALUES ('[email protected]')
Columns
| Name | Type | ReadOnly | References | Description |
| Id [KEY] | Long | True |
The unique identifier for the resource. | |
| DateCreated | Datetime | True |
The date the customer was created, in the site's timezone. | |
| DateModified | Datetime | True |
The date the customer was last modified, in the site's timezone. | |
| String | False |
The email address for the customer. | ||
| FirstName | String | False |
The customer's first name. | |
| LastName | String | False |
The customer's last name. | |
| Role | String | True |
The customer role. Includes all roles by default. The allowed values are administrator, editor, author, contributor, subscriber, customer, shop_manager. | |
| Username | String | False |
The customer login name. | |
| Password | String | False |
The customer password. | |
| IsPayingCustomer | Bool | True |
Indicates whether the customer is a paying customer. | |
| AvatarUrl | String | True |
The avatar URL. | |
| MetaDataAggregate | String | False |
The customer metadata. See CustomerMetadata properties. | |
| BillingFirstName | String | False |
The billing first name. | |
| BillingLastName | String | False |
The billing last name. | |
| BillingCompany | String | False |
The billing company name. | |
| BillingAddress1 | String | False |
The billing address line 1. | |
| BillingAddress2 | String | False |
The billing address line 2. | |
| BillingCity | String | False |
The billing city name. | |
| BillingState | String | False |
The ISO code or name of the billing state, province or district. | |
| BillingPostcode | String | False |
The billing postal code. | |
| BillingCountry | String | False |
The ISO code of the billing country. | |
| BillingEmail | String | False |
The billing email address. | |
| BillingPhone | String | False |
The billing phone number. | |
| ShippingFirstName | String | False |
The shipping first name. | |
| ShippingLastName | String | False |
The shipping last name. | |
| ShippingCompany | String | False |
The shipping company name. | |
| ShippingAddress1 | String | False |
The shipping address line 1. | |
| ShippingAddress2 | String | False |
The shipping address line 2. | |
| ShippingCity | String | False |
The shipping city name. | |
| ShippingState | String | False |
The shipping ISO code or name of the state, province or district. | |
| ShippingPostcode | String | False |
The shipping postal code. | |
| ShippingCountry | String | False |
The shipping ISO code of the country. |
Pseudo-Columns
Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.
| Name | Type | Description |
| ReferenceNumber | String |
This column is used in Bulk operations to get specific values from the Temp tables. |