PHP Class WC_API_Customers

Inheritance: extends WC_API_Resource
Afficher le fichier Open project: woocommerce/woocommerce Class Usage Examples

Protected Properties

Свойство Type Description
$base string the route base

Méthodes publiques

Méthode Description
__construct ( WC_API_Server $server ) : WC_API_Customers Setup class, overridden to provide customer data to order response
add_customer_data ( $order_data, $order ) : array Add customer data to orders
bulk ( array $data ) : array Bulk update or insert customers Accepts an array with customers in the formats supported by WC_API_Customers->create_customer() and WC_API_Customers->edit_customer()
create_customer ( array $data ) : array Create a customer
delete_customer ( integer $id ) : array Delete a customer
edit_customer ( integer $id, array $data ) : array Edit a customer
get_customer ( integer $id, array $fields = null ) : array Get the customer for the given ID
get_customer ( integer $id, string $fields = null ) : array Get the customer for the given ID
get_customer_by_email ( string $email, array $fields = null ) : array Get the customer for the given email
get_customer_downloads ( integer $id, string $fields = null ) : array Get the available downloads for a customer
get_customer_orders ( integer $id, string $fields = null ) : array Get the orders for a customer
get_customer_orders ( integer $id, string $fields = null, array $filter = [] ) : array Get the orders for a customer
get_customers ( array $fields = null, array $filter = [], integer $page = 1 ) : array Get all customers
get_customers_count ( array $filter = [] ) : array Get the total number of customers
modify_user_query ( WP_User_Query $query ) Modify the WP_User_Query to support filtering on the date the customer was created
register_routes ( array $routes ) : array Register the routes for this class

Méthodes protégées

Méthode Description
get_customer_billing_address ( ) : array Get customer billing address fields.
get_customer_shipping_address ( ) : array Get customer shipping address fields.
is_readable ( integer | WP_Post $post ) : boolean Check if the current user can read users
update_customer_data ( integer $id, array $data, WC_Customer $customer ) Add/Update customer data.
validate_request ( integer $id, string $type, string $context ) : integer | WP_Error Validate the request by checking:
validate_request ( string | integer $id, string $type, string $context ) : integer | WP_Error Validate the request by checking:

Private Methods

Méthode Description
query_customers ( array $args = [] ) : WP_User_Query Helper method to get customer user objects

Method Details

__construct() public méthode

Setup class, overridden to provide customer data to order response
Since: 2.1
public __construct ( WC_API_Server $server ) : WC_API_Customers
$server WC_API_Server
Résultat WC_API_Customers

add_customer_data() public méthode

Add customer data to orders
Since: 2.1
public add_customer_data ( $order_data, $order ) : array
$order_data
$order
Résultat array

bulk() public méthode

Bulk update or insert customers Accepts an array with customers in the formats supported by WC_API_Customers->create_customer() and WC_API_Customers->edit_customer()
Since: 2.4.0
public bulk ( array $data ) : array
$data array
Résultat array

create_customer() public méthode

Create a customer
Since: 2.2
public create_customer ( array $data ) : array
$data array
Résultat array

delete_customer() public méthode

Delete a customer
Since: 2.2
public delete_customer ( integer $id ) : array
$id integer the customer ID
Résultat array

edit_customer() public méthode

Edit a customer
Since: 2.2
public edit_customer ( integer $id, array $data ) : array
$id integer the customer ID
$data array
Résultat array

get_customer() public méthode

Get the customer for the given ID
Since: 2.1
public get_customer ( integer $id, array $fields = null ) : array
$id integer the customer ID
$fields array
Résultat array

get_customer() public méthode

Get the customer for the given ID
Since: 2.1
public get_customer ( integer $id, string $fields = null ) : array
$id integer the customer ID
$fields string
Résultat array

get_customer_billing_address() protected méthode

Get customer billing address fields.
Since: 2.2
protected get_customer_billing_address ( ) : array
Résultat array

get_customer_by_email() public méthode

Get the customer for the given email
Since: 2.1
public get_customer_by_email ( string $email, array $fields = null ) : array
$email string the customer email
$fields array
Résultat array

get_customer_downloads() public méthode

Get the available downloads for a customer
Since: 2.2
public get_customer_downloads ( integer $id, string $fields = null ) : array
$id integer the customer ID
$fields string fields to include in response
Résultat array

get_customer_orders() public méthode

Get the orders for a customer
Since: 2.1
public get_customer_orders ( integer $id, string $fields = null ) : array
$id integer the customer ID
$fields string fields to include in response
Résultat array

get_customer_orders() public méthode

Get the orders for a customer
Since: 2.1
public get_customer_orders ( integer $id, string $fields = null, array $filter = [] ) : array
$id integer the customer ID
$fields string fields to include in response
$filter array filters
Résultat array

get_customer_shipping_address() protected méthode

Get customer shipping address fields.
Since: 2.2
protected get_customer_shipping_address ( ) : array
Résultat array

get_customers() public méthode

Get all customers
Since: 2.1
public get_customers ( array $fields = null, array $filter = [], integer $page = 1 ) : array
$fields array
$filter array
$page integer
Résultat array

get_customers_count() public méthode

Get the total number of customers
Since: 2.1
public get_customers_count ( array $filter = [] ) : array
$filter array
Résultat array

is_readable() protected méthode

Check if the current user can read users
See also: WC_API_Resource::is_readable()
Since: 2.1
protected is_readable ( integer | WP_Post $post ) : boolean
$post integer | WP_Post unused
Résultat boolean true if the current user can read users, false otherwise

modify_user_query() public méthode

Modify the WP_User_Query to support filtering on the date the customer was created
Since: 2.1
public modify_user_query ( WP_User_Query $query )
$query WP_User_Query

register_routes() public méthode

GET /customers GET /customers/count GET /customers/ GET /customers//orders
Since: 2.2
public register_routes ( array $routes ) : array
$routes array
Résultat array

update_customer_data() protected méthode

Add/Update customer data.
Since: 2.2
protected update_customer_data ( integer $id, array $data, WC_Customer $customer )
$id integer the customer ID
$data array
$customer WC_Customer

validate_request() protected méthode

1) the ID is a valid integer 2) the ID returns a valid WP_User 3) the current user has the proper permissions
See also: WC_API_Resource::validate_request()
Since: 2.1
protected validate_request ( integer $id, string $type, string $context ) : integer | WP_Error
$id integer the customer ID
$type string the request type, unused because this method overrides the parent class
$context string the context of the request, either `read`, `edit` or `delete`
Résultat integer | WP_Error valid user ID or WP_Error if any of the checks fails

validate_request() protected méthode

1) the ID is a valid integer 2) the ID returns a valid WP_User 3) the current user has the proper permissions
See also: WC_API_Resource::validate_request()
Since: 2.1
protected validate_request ( string | integer $id, string $type, string $context ) : integer | WP_Error
$id string | integer the customer ID
$type string the request type, unused because this method overrides the parent class
$context string the context of the request, either `read`, `edit` or `delete`
Résultat integer | WP_Error valid user ID or WP_Error if any of the checks fails

Property Details

$base protected_oe property

the route base
protected string $base
Résultat string