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 |
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 |
Customer first name. | |
| LastName | String | False |
Customer last name. | |
| Role | String | True |
Customer role. Includes all roles by default. The allowed values are administrator, editor, author, contributor, subscriber, customer, shop_manager. | |
| Username | String | False |
Customer login name. | |
| Password | String | False |
Customer password. write-only | |
| IsPayingCustomer | Bool | True |
Is the customer a paying customer? read-only | |
| AvatarUrl | String | True |
Avatar URL. | |
| MetaDataAggregate | String | False |
Meta data. See Customer - Meta data properties | |
| BillingFirstName | String | False |
First name. | |
| BillingLastName | String | False |
Last name. | |
| BillingCompany | String | False |
Company name. | |
| BillingAddress1 | String | False |
Address line 1 | |
| BillingAddress2 | String | False |
Address line 2 | |
| BillingCity | String | False |
City name. | |
| BillingState | String | False |
ISO code or name of the state, province or district. | |
| BillingPostcode | String | False |
Postal code. | |
| BillingCountry | String | False |
ISO code of the country. | |
| BillingEmail | String | False |
Email address. | |
| BillingPhone | String | False |
Phone number. | |
| ShippingFirstName | String | False |
First name. | |
| ShippingLastName | String | False |
Last name. | |
| ShippingCompany | String | False |
Company name. | |
| ShippingAddress1 | String | False |
Address line 1 | |
| ShippingAddress2 | String | False |
Address line 2 | |
| ShippingCity | String | False |
City name. | |
| ShippingState | String | False |
ISO code or name of the state, province or district. | |
| ShippingPostcode | String | False |
Postal code. | |
| ShippingCountry | String | False |
ISO code of the country. |
Pseudo-Columns
Pseudo column fields are used in the WHERE clause of SELECT statements and offer more granular control over the data returned from the data source.
| Name | Type | Description |
| ReferenceNumber | String |
This column will be used in Bulk operations to get specific values from the Temp tables. |