Class WC_API_Customers

WC_API_Resource
Extended by WC_API_Customers
Package: WooCommerce\API
Author: WooThemes
Located at includes/api/class-wc-api-customers.php

Methods summary

public WC_API_Customers
# __construct( WC_API_Server $server )

Setup class, overridden to provide customer data to order response

Setup class, overridden to provide customer data to order response

Parameters

$server
WC_API_Server
$server

Returns

WC_API_Customers

Since

2.1

Overrides

WC_API_Resource::__construct
public array
# register_routes( array $routes )

Register the routes for this class

Register the routes for this class

GET /customers GET /customers/count GET /customers/<id> GET /customers/<id>/orders

Parameters

$routes
array
$routes

Returns

array

Since

2.1
public array
# get_customers( array $fields = null, array $filter = array(), integer $page = 1 )

Get all customers

Get all customers

Parameters

$fields
array
$fields
$filter
array
$filter
$page
integer
$page

Returns

array

Since

2.1
public array
# get_customer( integer $id, string $fields = null )

Get the customer for the given ID

Get the customer for the given ID

Parameters

$id
integer
$id the customer ID
$fields
string
$fields

Returns

array

Since

2.1
public array
# get_customers_count( array $filter = array() )

Get the total number of customers

Get the total number of customers

Parameters

$filter
array
$filter

Returns

array

Since

2.1
public array
# create_customer( array $data )

Create a customer

Create a customer

Parameters

$data
array
$data

Returns

array

TODO

implement in 2.2 with woocommerce_create_new_customer()
public array
# edit_customer( integer $id, array $data )

Edit a customer

Edit a customer

Parameters

$id
integer
$id the customer ID
$data
array
$data

Returns

array

TODO

implement in 2.2
public array
# delete_customer( integer $id )

Delete a customer

Delete a customer

Parameters

$id
integer
$id the customer ID

Returns

array

TODO

enable along with PUT/POST in 2.2
public array
# get_customer_orders( integer $id, string $fields = null )

Get the orders for a customer

Get the orders for a customer

Parameters

$id
integer
$id the customer ID
$fields
string
$fields fields to include in response

Returns

array

Since

2.1
public array
# add_customer_data( mixed $order_data, mixed $order )

Add customer data to orders

Add customer data to orders

Parameters

$order_data
mixed
$order_data
$order
mixed
$order

Returns

array

Since

2.1
public
# modify_user_query( WP_User_Query $query )

Modify the WP_User_Query to support filtering on the date the customer was created

Modify the WP_User_Query to support filtering on the date the customer was created

Parameters

$query
WP_User_Query
$query

Since

2.1
protected integer|WP_Error
# validate_request( string|integer $id, string $type, string $context )

Validate the request by checking:

Validate the request by checking:

  1. the ID is a valid integer
  2. the ID returns a valid WP_User
  3. the current user has the proper permissions

Parameters

$id
string|integer
$id the customer ID
$type
string
$type the request type, unused because this method overrides the parent class
$context
string
$context the context of the request, either read, edit or delete

Returns

integer|WP_Error
valid user ID or WP_Error if any of the checks fails

Since

2.1

See

WC_API_Resource::validate_request()

Overrides

WC_API_Resource::validate_request
protected boolean
# is_readable( integer|WP_Post $post )

Check if the current user can read users

Check if the current user can read users

Parameters

$post
integer|WP_Post
$post unused

Returns

boolean
true if the current user can read users, false otherwise

Since

2.1

See

WC_API_Resource::is_readable()

Overrides

WC_API_Resource::is_readable

Methods inherited from WC_API_Resource

delete(), filter_response_fields(), is_deletable(), is_editable(), maybe_add_meta(), merge_query_args()

Magic methods summary

Properties summary

protected string $base
#

$base the route base

$base the route base

Properties inherited from WC_API_Resource

$server

WooCommerce API documentation generated by ApiGen 2.8.0