WooCommerce Code Reference

Search results

WC_Customer extends WC_Legacy_Customer

Customer class.

Implemented by classes using the same CRUD(s) pattern.

Table of Contents

$data Stores customer data. array
$password Stores a password if this needs to be changed. Write-only and hidden from _data. string
$is_vat_exempt Stores if user is VAT exempt for this session. string
$calculated_shipping Stores if user has calculated shipping in this session. string
$id ID for this object. int
$data Core data for this object. Name value pairs (name + default value). array
$changes Core data changes for this object. array
$object_read This is false until the object is read from the DB. bool
$object_type This is the name of this object type. string
$extra_data Extra data for this object. Name value pairs (name + default value). array
$default_data Set to _data on construct so we can track and reset data if needed. array
$data_store Contains a reference to the data store for this class. object
$cache_group Stores meta in cache for future reads. string
$meta_data Stores additional meta data. array
__construct() Load customer data based on how WC_Customer is called. mixed
get_hook_prefix() Prefix for action and filter hooks on data. string
delete_and_reassign() Delete a customer and reassign posts. bool
is_customer_outside_base() Is customer outside base country (for tax purposes)? bool
get_avatar_url() Return this customer's avatar. string
get_taxable_address() Get taxable address. array
get_downloadable_products() Gets a customer's downloadable products. array
is_vat_exempt() Is customer VAT exempt? bool
has_calculated_shipping() Has calculated shipping? bool
get_is_vat_exempt() Get if customer is VAT exempt? bool
get_password() Get password (only used when updating the user object). string
get_calculated_shipping() Has customer calculated shipping? bool
set_is_vat_exempt() Set if customer has tax exemption. mixed
set_calculated_shipping() Calculated shipping? mixed
set_password() Set customer's password. mixed
get_last_order() Gets the customers last order. WC_Order|false
get_order_count() Return the number of orders this customer has. int
get_total_spent() Return how much money this customer has spent. float
get_username() Return the customer's username. string
get_email() Return the customer's email. string
get_first_name() Return customer's first name. string
get_last_name() Return customer's last name. string
get_display_name() Return customer's display name. string
get_role() Return customer's user role. string
get_date_created() Return the date this customer was created. WC_DateTime|null
get_date_modified() Return the date this customer was last updated. WC_DateTime|null
get_address_prop() Gets a prop for a getter method. mixed
get_billing() Get billing. array
get_billing_first_name() Get billing_first_name. string
get_billing_last_name() Get billing_last_name. string
get_billing_company() Get billing_company. string
get_billing_address() Get billing_address_1. string
get_billing_address_1() Get billing_address_1. string
get_billing_address_2() Get billing_address_2. string
get_billing_city() Get billing_city. string
get_billing_state() Get billing_state. string
get_billing_postcode() Get billing_postcode. string
get_billing_country() Get billing_country. string
get_billing_email() Get billing_email. string
get_billing_phone() Get billing_phone. string
get_shipping() Get shipping. array
get_shipping_first_name() Get shipping_first_name. string
get_shipping_last_name() Get shipping_last_name. string
get_shipping_company() Get shipping_company. string
get_shipping_address() Get shipping_address_1. string
get_shipping_address_1() Get shipping_address_1. string
get_shipping_address_2() Get shipping_address_2. string
get_shipping_city() Get shipping_city. string
get_shipping_state() Get shipping_state. string
get_shipping_postcode() Get shipping_postcode. string
get_shipping_country() Get shipping_country. string
get_is_paying_customer() Is the user a paying customer? bool
set_username() Set customer's username. mixed
set_email() Set customer's email. mixed
set_first_name() Set customer's first name. mixed
set_last_name() Set customer's last name. mixed
set_display_name() Set customer's display name. mixed
set_role() Set customer's user role(s). mixed
set_date_created() Set the date this customer was last updated. mixed
set_date_modified() Set the date this customer was last updated. mixed
set_billing_address_to_base() Set customer address to match shop base address. mixed
set_shipping_address_to_base() Set customer shipping address to base address. mixed
set_billing_location() Sets all address info at once. mixed
set_shipping_location() Sets all shipping info at once. mixed
set_address_prop() Sets a prop for a setter method. mixed
set_billing_first_name() Set billing_first_name. mixed
set_billing_last_name() Set billing_last_name. mixed
set_billing_company() Set billing_company. mixed
set_billing_address() Set billing_address_1. mixed
set_billing_address_1() Set billing_address_1. mixed
set_billing_address_2() Set billing_address_2. mixed
set_billing_city() Set billing_city. mixed
set_billing_state() Set billing_state. mixed
set_billing_postcode() Set billing_postcode. mixed
set_billing_country() Set billing_country. mixed
set_billing_email() Set billing_email. mixed
set_billing_phone() Set billing_phone. mixed
set_shipping_first_name() Set shipping_first_name. mixed
set_shipping_last_name() Set shipping_last_name. mixed
set_shipping_company() Set shipping_company. mixed
set_shipping_address() Set shipping_address_1. mixed
set_shipping_address_1() Set shipping_address_1. mixed
set_shipping_address_2() Set shipping_address_2. mixed
set_shipping_city() Set shipping_city. mixed
set_shipping_state() Set shipping_state. mixed
set_shipping_postcode() Set shipping_postcode. mixed
set_shipping_country() Set shipping_country. mixed
set_is_paying_customer() Set if the user a paying customer. mixed
__isset() __isset legacy. bool
__get() __get function. string
__set() __set function. mixed
filter_legacy_key() Address and shipping_address are aliased, so we want to get the 'real' key name. string
set_location() Sets session data for the location. mixed
get_default_country() Get default country for a customer. string
get_default_state() Get default state for a customer. string
set_to_base() Set customer address to match shop base address. mixed
set_shipping_to_base() Set customer shipping address to base address. mixed
calculated_shipping() Calculated shipping. mixed
set_default_data() Set default data for a customer. mixed
save_data() Save data function. mixed
is_paying_customer() Is the user a paying customer? bool
get_address() Legacy get address. mixed
get_address_2() Legacy get address 2. mixed
get_country() Legacy get country. mixed
get_state() Legacy get state. mixed
get_postcode() Legacy get postcode. mixed
get_city() Legacy get city. mixed
set_country() Legacy set country. mixed
set_state() Legacy set state. mixed
set_postcode() Legacy set postcode. mixed
set_city() Legacy set city. mixed
set_address() Legacy set address. mixed
set_address_2() Legacy set address. mixed
__construct() Default constructor. mixed
__sleep() Only store the object ID to avoid serializing the data object instance. array
__wakeup() Re-run the constructor with the object ID. mixed
__clone() When the object is cloned, make sure meta is duplicated correctly. mixed
get_data_store() Get the data store. object
get_id() Returns the unique ID for this object. int
delete() Delete an object, set the ID to 0, and return result. bool
save() Save should create or update based on object existence. int
__toString() Change data to JSON format. string
get_data() Returns all data for this object. array
get_data_keys() Returns array of expected data keys for this object. array
get_extra_data_keys() Returns all "extra" data keys for an object (for sub objects like product types). array
filter_null_meta() Filter null meta values from array. bool
get_meta_data() Get All Meta Data. array
is_internal_meta_key() Check if the key is an internal one. bool
get_meta() Get Meta Data by Key. mixed
meta_exists() See if meta data exists, since get_meta always returns a '' or array(). bool
set_meta_data() Set all meta data from array. mixed
add_meta_data() Add meta data. mixed
update_meta_data() Update meta data by key or ID, if provided. mixed
delete_meta_data() Delete meta data. mixed
delete_meta_data_by_mid() Delete meta data. mixed
maybe_read_meta_data() Read meta data if null. mixed
read_meta_data() Read Meta Data from the database. Ignore any internal properties. mixed
save_meta_data() Update Meta Data in the database. mixed
set_id() Set ID. mixed
set_defaults() Set all props to default values. mixed
set_object_read() Set object read property. mixed
get_object_read() Get object read property. bool
set_props() Set a collection of props in one go, collect any errors, and return the result. bool|WP_Error
set_prop() Sets a prop for a setter method. mixed
get_changes() Return data changes only. array
apply_changes() Merge changes with data and clear. mixed
get_hook_prefix() Prefix for action and filter hooks on data. string
get_prop() Gets a prop for a getter method. mixed
set_date_prop() Sets a date prop whilst handling formatting and datetime objects. mixed
error() When invalid data is found, throw an exception unless reading from the DB. mixed

Properties

$data

Stores customer data.

protected array $data = array('date_created' => \null, 'date_modified' => \null, 'email' => '', 'first_name' => '', 'last_name' => '', 'display_name' => '', 'role' => 'customer', 'username' => '', 'billing' => array('first_name' => '', 'last_name' => '', 'company' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'postcode' => '', 'country' => '', 'state' => '', 'email' => '', 'phone' => ''), 'shipping' => array('first_name' => '', 'last_name' => '', 'company' => '', 'address_1' => '', 'address_2' => '', 'city' => '', 'postcode' => '', 'country' => '', 'state' => ''), 'is_paying_customer' => \false)

$password

Stores a password if this needs to be changed. Write-only and hidden from _data.

protected string $password = ''

$is_vat_exempt

Stores if user is VAT exempt for this session.

protected string $is_vat_exempt = \false

$calculated_shipping

Stores if user has calculated shipping in this session.

protected string $calculated_shipping = \false

$data

Core data for this object. Name value pairs (name + default value).

protected array $data = array()

$changes

Core data changes for this object.

protected array $changes = array()

$object_read

This is false until the object is read from the DB.

protected bool $object_read = \false

$object_type

This is the name of this object type.

protected string $object_type = 'data'

$extra_data

Extra data for this object. Name value pairs (name + default value).

protected array $extra_data = array()
Used as a standard way for sub classes (like product types) to add additional information to an inherited class.

$default_data

Set to _data on construct so we can track and reset data if needed.

protected array $default_data = array()

$data_store

Contains a reference to the data store for this class.

protected object $data_store

$cache_group

Stores meta in cache for future reads.

protected string $cache_group = ''
A group must be set to to enable caching.

$meta_data

Stores additional meta data.

protected array $meta_data = \null

Methods

__construct()

Load customer data based on how WC_Customer is called.

public __construct( $data : WC_Customer|int [, $is_session : bool = false ] ) : mixed

If $customer is 'new', you can build a new WC_Customer object. If it's empty, some data will be pulled from the session for the current user/customer.

Parameters
$data : WC_Customer|int

Customer ID or data.

$is_session : bool = false

True if this is the customer session.

Tags
throws

If customer cannot be read/found and $data is set.

Return values
mixed

get_hook_prefix()

Prefix for action and filter hooks on data.

protected get_hook_prefix( ) : string
Tags
since
Return values
string

delete_and_reassign()

Delete a customer and reassign posts.

public delete_and_reassign( [ $reassign : int = null ] ) : bool

.

Parameters
$reassign : int = null

Reassign posts and links to new User ID.

Tags
since
Return values
bool

is_customer_outside_base()

Is customer outside base country (for tax purposes)?

public is_customer_outside_base( ) : bool
Return values
bool

get_avatar_url()

Return this customer's avatar.

public get_avatar_url( ) : string
Tags
since
Return values
string

get_taxable_address()

Get taxable address.

public get_taxable_address( ) : array
Return values
array

get_downloadable_products()

Gets a customer's downloadable products.

public get_downloadable_products( ) : array
Return values
array

Array of downloadable products

is_vat_exempt()

Is customer VAT exempt?

public is_vat_exempt( ) : bool
Return values
bool

has_calculated_shipping()

Has calculated shipping?

public has_calculated_shipping( ) : bool
Return values
bool

get_is_vat_exempt()

Get if customer is VAT exempt?

public get_is_vat_exempt( ) : bool
Tags
since
Return values
bool

get_password()

Get password (only used when updating the user object).

public get_password( ) : string
Return values
string

get_calculated_shipping()

Has customer calculated shipping?

public get_calculated_shipping( ) : bool
Return values
bool

set_is_vat_exempt()

Set if customer has tax exemption.

public set_is_vat_exempt( $is_vat_exempt : bool ) : mixed
Parameters
$is_vat_exempt : bool

If is vat exempt.

Return values
mixed

set_calculated_shipping()

Calculated shipping?

public set_calculated_shipping( [ $calculated : bool = true ] ) : mixed
Parameters
$calculated : bool = true

If shipping is calculated.

Return values
mixed

set_password()

Set customer's password.

public set_password( $password : string ) : mixed
Parameters
$password : string

Password.

Tags
since
Return values
mixed

get_order_count()

Return the number of orders this customer has.

public get_order_count( ) : int
Return values
int

get_total_spent()

Return how much money this customer has spent.

public get_total_spent( ) : float
Return values
float

get_username()

Return the customer's username.

public get_username( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
string

get_email()

Return the customer's email.

public get_email( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
string

get_first_name()

Return customer's first name.

public get_first_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
string

get_last_name()

Return customer's last name.

public get_last_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
string

get_display_name()

Return customer's display name.

public get_display_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
string

get_role()

Return customer's user role.

public get_role( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
string

get_date_created()

Return the date this customer was created.

public get_date_created( [ $context : string = 'view' ] ) : WC_DateTime|null
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
WC_DateTime|null

object if the date is set or null if there is no date.

get_date_modified()

Return the date this customer was last updated.

public get_date_modified( [ $context : string = 'view' ] ) : WC_DateTime|null
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
WC_DateTime|null

object if the date is set or null if there is no date.

get_address_prop()

Gets a prop for a getter method.

protected get_address_prop( $prop : string [, $address : string = 'billing' ] [, $context : string = 'view' ] ) : mixed
Parameters
$prop : string

Name of prop to get.

$address : string = 'billing'

billing or shipping.

$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'. What the value is for. Valid values are view and edit.

Tags
since
Return values
mixed

get_billing()

Get billing.

public get_billing( [ $context : string = 'view' ] ) : array
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
array

get_billing_first_name()

Get billing_first_name.

public get_billing_first_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_last_name()

Get billing_last_name.

public get_billing_last_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_company()

Get billing_company.

public get_billing_company( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_address()

Get billing_address_1.

public get_billing_address( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_address_1()

Get billing_address_1.

public get_billing_address_1( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_address_2()

Get billing_address_2.

public get_billing_address_2( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

$value

get_billing_city()

Get billing_city.

public get_billing_city( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

$value

get_billing_state()

Get billing_state.

public get_billing_state( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_postcode()

Get billing_postcode.

public get_billing_postcode( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_country()

Get billing_country.

public get_billing_country( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_email()

Get billing_email.

public get_billing_email( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_billing_phone()

Get billing_phone.

public get_billing_phone( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping()

Get shipping.

public get_shipping( [ $context : string = 'view' ] ) : array
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
array

get_shipping_first_name()

Get shipping_first_name.

public get_shipping_first_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_last_name()

Get shipping_last_name.

public get_shipping_last_name( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_company()

Get shipping_company.

public get_shipping_company( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_address()

Get shipping_address_1.

public get_shipping_address( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_address_1()

Get shipping_address_1.

public get_shipping_address_1( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_address_2()

Get shipping_address_2.

public get_shipping_address_2( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_city()

Get shipping_city.

public get_shipping_city( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_state()

Get shipping_state.

public get_shipping_state( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_postcode()

Get shipping_postcode.

public get_shipping_postcode( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_shipping_country()

Get shipping_country.

public get_shipping_country( [ $context : string = 'view' ] ) : string
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Return values
string

get_is_paying_customer()

Is the user a paying customer?

public get_is_paying_customer( [ $context : string = 'view' ] ) : bool
Parameters
$context : string = 'view'

What the value is for. Valid values are 'view' and 'edit'.

Tags
since
Return values
bool

set_username()

Set customer's username.

public set_username( $username : string ) : mixed
Parameters
$username : string

Username.

Tags
since
Return values
mixed

set_email()

Set customer's email.

public set_email( $value : string ) : mixed
Parameters
$value : string

Email.

Tags
since
Return values
mixed

set_first_name()

Set customer's first name.

public set_first_name( $first_name : string ) : mixed
Parameters
$first_name : string

First name.

Tags
since
Return values
mixed

set_last_name()

Set customer's last name.

public set_last_name( $last_name : string ) : mixed
Parameters
$last_name : string

Last name.

Tags
since
Return values
mixed

set_display_name()

Set customer's display name.

public set_display_name( $display_name : string ) : mixed
Parameters
$display_name : string

Display name.

Tags
since
Return values
mixed

set_role()

Set customer's user role(s).

public set_role( $role : mixed ) : mixed
Parameters
$role : mixed

User role.

Tags
since
Return values
mixed

set_date_created()

Set the date this customer was last updated.

public set_date_created( [ $date : string|int|null = null ] ) : mixed
Parameters
$date : string|int|null = null

UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.

Tags
since
Return values
mixed

set_date_modified()

Set the date this customer was last updated.

public set_date_modified( [ $date : string|int|null = null ] ) : mixed
Parameters
$date : string|int|null = null

UTC timestamp, or ISO 8601 DateTime. If the DateTime string has no timezone or offset, WordPress site timezone will be assumed. Null if their is no date.

Tags
since
Return values
mixed

set_billing_address_to_base()

Set customer address to match shop base address.

public set_billing_address_to_base( ) : mixed
Tags
since
Return values
mixed

set_shipping_address_to_base()

Set customer shipping address to base address.

public set_shipping_address_to_base( ) : mixed
Tags
since
Return values
mixed

set_billing_location()

Sets all address info at once.

public set_billing_location( $country : string [, $state : string = '' ] [, $postcode : string = '' ] [, $city : string = '' ] ) : mixed
Parameters
$country : string

Country.

$state : string = ''

State.

$postcode : string = ''

Postcode.

$city : string = ''

City.

Return values
mixed

set_shipping_location()

Sets all shipping info at once.

public set_shipping_location( $country : string [, $state : string = '' ] [, $postcode : string = '' ] [, $city : string = '' ] ) : mixed
Parameters
$country : string

Country.

$state : string = ''

State.

$postcode : string = ''

Postcode.

$city : string = ''

City.

Return values
mixed

set_address_prop()

Sets a prop for a setter method.

protected set_address_prop( $prop : string [, $address : string = 'billing' ] , $value : mixed ) : mixed
Parameters
$prop : string

Name of prop to set.

$address : string = 'billing'

Name of address to set. billing or shipping.

$value : mixed

Value of the prop.

Tags
since
Return values
mixed

set_billing_first_name()

Set billing_first_name.

public set_billing_first_name( $value : string ) : mixed
Parameters
$value : string

Billing first name.

Return values
mixed

set_billing_last_name()

Set billing_last_name.

public set_billing_last_name( $value : string ) : mixed
Parameters
$value : string

Billing last name.

Return values
mixed

set_billing_company()

Set billing_company.

public set_billing_company( $value : string ) : mixed
Parameters
$value : string

Billing company.

Return values
mixed

set_billing_address()

Set billing_address_1.

public set_billing_address( $value : string ) : mixed
Parameters
$value : string

Billing address line 1.

Return values
mixed

set_billing_address_1()

Set billing_address_1.

public set_billing_address_1( $value : string ) : mixed
Parameters
$value : string

Billing address line 1.

Return values
mixed

set_billing_address_2()

Set billing_address_2.

public set_billing_address_2( $value : string ) : mixed
Parameters
$value : string

Billing address line 2.

Return values
mixed

set_billing_city()

Set billing_city.

public set_billing_city( $value : string ) : mixed
Parameters
$value : string

Billing city.

Return values
mixed

set_billing_state()

Set billing_state.

public set_billing_state( $value : string ) : mixed
Parameters
$value : string

Billing state.

Return values
mixed

set_billing_postcode()

Set billing_postcode.

public set_billing_postcode( $value : string ) : mixed
Parameters
$value : string

Billing postcode.

Return values
mixed

set_billing_country()

Set billing_country.

public set_billing_country( $value : string ) : mixed
Parameters
$value : string

Billing country.

Return values
mixed

set_billing_email()

Set billing_email.

public set_billing_email( $value : string ) : mixed
Parameters
$value : string

Billing email.

Return values
mixed

set_billing_phone()

Set billing_phone.

public set_billing_phone( $value : string ) : mixed
Parameters
$value : string

Billing phone.

Return values
mixed

set_shipping_first_name()

Set shipping_first_name.

public set_shipping_first_name( $value : string ) : mixed
Parameters
$value : string

Shipping first name.

Return values
mixed

set_shipping_last_name()

Set shipping_last_name.

public set_shipping_last_name( $value : string ) : mixed
Parameters
$value : string

Shipping last name.

Return values
mixed

set_shipping_company()

Set shipping_company.

public set_shipping_company( $value : string ) : mixed
Parameters
$value : string

Shipping company.

Return values
mixed

set_shipping_address()

Set shipping_address_1.

public set_shipping_address( $value : string ) : mixed
Parameters
$value : string

Shipping address line 1.

Return values
mixed

set_shipping_address_1()

Set shipping_address_1.

public set_shipping_address_1( $value : string ) : mixed
Parameters
$value : string

Shipping address line 1.

Return values
mixed

set_shipping_address_2()

Set shipping_address_2.

public set_shipping_address_2( $value : string ) : mixed
Parameters
$value : string

Shipping address line 2.

Return values
mixed

set_shipping_city()

Set shipping_city.

public set_shipping_city( $value : string ) : mixed
Parameters
$value : string

Shipping city.

Return values
mixed

set_shipping_state()

Set shipping_state.

public set_shipping_state( $value : string ) : mixed
Parameters
$value : string

Shipping state.

Return values
mixed

set_shipping_postcode()

Set shipping_postcode.

public set_shipping_postcode( $value : string ) : mixed
Parameters
$value : string

Shipping postcode.

Return values
mixed

set_shipping_country()

Set shipping_country.

public set_shipping_country( $value : string ) : mixed
Parameters
$value : string

Shipping country.

Return values
mixed

set_is_paying_customer()

Set if the user a paying customer.

public set_is_paying_customer( $is_paying_customer : bool ) : mixed
Parameters
$is_paying_customer : bool

If is a paying customer.

Tags
since
Return values
mixed

__isset()

__isset legacy.

public __isset( $key : mixed ) : bool
Parameters
$key : mixed
Return values
bool

__get()

__get function.

public __get( $key : string ) : string
Parameters
$key : string
Return values
string

__set()

__set function.

public __set( $key : string , $value : mixed ) : mixed
Parameters
$key : string
$value : mixed
Return values
mixed

filter_legacy_key()

Address and shipping_address are aliased, so we want to get the 'real' key name.

private filter_legacy_key( $key : string ) : string

For all other keys, we can just return it.

Parameters
$key : string
Tags
since
Return values
string

set_location()

Sets session data for the location.

public set_location( $country : string , $state : string [, $postcode : string = '' ] [, $city : string = '' ] ) : mixed
Parameters
$country : string
$state : string
$postcode : string = ''

(default: '')

$city : string = ''

(default: '')

Return values
mixed

get_default_country()

Get default country for a customer.

public get_default_country( ) : string
Return values
string

get_default_state()

Get default state for a customer.

public get_default_state( ) : string
Return values
string

set_to_base()

Set customer address to match shop base address.

public set_to_base( ) : mixed
Return values
mixed

set_shipping_to_base()

Set customer shipping address to base address.

public set_shipping_to_base( ) : mixed
Return values
mixed

calculated_shipping()

Calculated shipping.

public calculated_shipping( [ $calculated : bool = true ] ) : mixed
Parameters
$calculated : bool = true
Return values
mixed

set_default_data()

Set default data for a customer.

public set_default_data( ) : mixed
Return values
mixed

is_paying_customer()

Is the user a paying customer?

public is_paying_customer( [ $user_id : int = '' ] ) : bool
Parameters
$user_id : int = ''
Return values
bool

set_country()

Legacy set country.

public set_country( $country : string ) : mixed
Parameters
$country : string
Return values
mixed

set_state()

Legacy set state.

public set_state( $state : string ) : mixed
Parameters
$state : string
Return values
mixed

set_postcode()

Legacy set postcode.

public set_postcode( $postcode : string ) : mixed
Parameters
$postcode : string
Return values
mixed

set_city()

Legacy set city.

public set_city( $city : string ) : mixed
Parameters
$city : string
Return values
mixed

set_address()

Legacy set address.

public set_address( $address : string ) : mixed
Parameters
$address : string
Return values
mixed

set_address_2()

Legacy set address.

public set_address_2( $address : string ) : mixed
Parameters
$address : string
Return values
mixed

__construct()

Default constructor.

public __construct( $read : int|object|array ) : mixed
Parameters
$read : int|object|array

ID to load from the DB (optional) or already queried data.

Return values
mixed

__sleep()

Only store the object ID to avoid serializing the data object instance.

public __sleep( ) : array
Return values
array

__wakeup()

Re-run the constructor with the object ID.

public __wakeup( ) : mixed

If the object no longer exists, remove the ID.

Return values
mixed

__clone()

When the object is cloned, make sure meta is duplicated correctly.

public __clone( ) : mixed
Tags
since
Return values
mixed

get_data_store()

Get the data store.

public get_data_store( ) : object
Tags
since
Return values
object

get_id()

Returns the unique ID for this object.

public get_id( ) : int
Tags
since
Return values
int

delete()

Delete an object, set the ID to 0, and return result.

public delete( [ $force_delete : bool = false ] ) : bool
Parameters
$force_delete : bool = false

Should the date be deleted permanently.

Tags
since
Return values
bool

result

save()

Save should create or update based on object existence.

public save( ) : int
Tags
since
Return values
int

__toString()

Change data to JSON format.

public __toString( ) : string
Tags
since
Return values
string

Data in JSON format.

get_data()

Returns all data for this object.

public get_data( ) : array
Tags
since
Return values
array

get_data_keys()

Returns array of expected data keys for this object.

public get_data_keys( ) : array
Tags
since
Return values
array

get_extra_data_keys()

Returns all "extra" data keys for an object (for sub objects like product types).

public get_extra_data_keys( ) : array
Tags
since
Return values
array

filter_null_meta()

Filter null meta values from array.

protected filter_null_meta( $meta : mixed ) : bool
Parameters
$meta : mixed

Meta value to check.

Tags
since
Return values
bool

get_meta_data()

Get All Meta Data.

public get_meta_data( ) : array
Tags
since
Return values
array

of objects.

is_internal_meta_key()

Check if the key is an internal one.

protected is_internal_meta_key( $key : string ) : bool
Parameters
$key : string

Key to check.

Tags
since
Return values
bool

true if it's an internal key, false otherwise

get_meta()

Get Meta Data by Key.

public get_meta( [ $key : string = '' ] [, $single : bool = true ] [, $context : string = 'view' ] ) : mixed
Parameters
$key : string = ''

Meta Key.

$single : bool = true

return first found meta with key, or all with $key.

$context : string = 'view'

What the value is for. Valid values are view and edit.

Tags
since
Return values
mixed

meta_exists()

See if meta data exists, since get_meta always returns a '' or array().

public meta_exists( [ $key : string = '' ] ) : bool
Parameters
$key : string = ''

Meta Key.

Tags
since
Return values
bool

set_meta_data()

Set all meta data from array.

public set_meta_data( $data : array ) : mixed
Parameters
$data : array

Key/Value pairs.

Tags
since
Return values
mixed

add_meta_data()

Add meta data.

public add_meta_data( $key : string , $value : string|array [, $unique : bool = false ] ) : mixed
Parameters
$key : string

Meta key.

$value : string|array

Meta value.

$unique : bool = false

Should this be a unique key?.

Tags
since
Return values
mixed

update_meta_data()

Update meta data by key or ID, if provided.

public update_meta_data( $key : string , $value : string|array , $meta_id : int ) : mixed
Parameters
$key : string

Meta key.

$value : string|array

Meta value.

$meta_id : int

Meta ID.

Tags
since
Return values
mixed

delete_meta_data()

Delete meta data.

public delete_meta_data( $key : string ) : mixed
Parameters
$key : string

Meta key.

Tags
since
Return values
mixed

delete_meta_data_by_mid()

Delete meta data.

public delete_meta_data_by_mid( $mid : int ) : mixed
Parameters
$mid : int

Meta ID.

Tags
since
Return values
mixed

maybe_read_meta_data()

Read meta data if null.

protected maybe_read_meta_data( ) : mixed
Tags
since
Return values
mixed

read_meta_data()

Read Meta Data from the database. Ignore any internal properties.

public read_meta_data( [ $force_read : bool = false ] ) : mixed

Uses it's own caches because get_metadata does not provide meta_ids.

Parameters
$force_read : bool = false

True to force a new DB read (and update cache).

Tags
since
Return values
mixed

save_meta_data()

Update Meta Data in the database.

public save_meta_data( ) : mixed
Tags
since
Return values
mixed

set_id()

Set ID.

public set_id( $id : int ) : mixed
Parameters
$id : int

ID.

Tags
since
Return values
mixed

set_defaults()

Set all props to default values.

public set_defaults( ) : mixed
Tags
since
Return values
mixed

set_object_read()

Set object read property.

public set_object_read( [ $read : bool = true ] ) : mixed
Parameters
$read : bool = true

Should read?.

Tags
since
Return values
mixed

get_object_read()

Get object read property.

public get_object_read( ) : bool
Tags
since
Return values
bool

set_props()

Set a collection of props in one go, collect any errors, and return the result.

public set_props( $props : array [, $context : string = 'set' ] ) : bool|WP_Error

Only sets using public methods.

Parameters
$props : array

Key value pairs to set. Key is the prop and should map to a setter function name.

$context : string = 'set'

In what context to run this.

Tags
since
Return values
bool|WP_Error

set_prop()

Sets a prop for a setter method.

protected set_prop( $prop : string , $value : mixed ) : mixed

This stores changes in a special array so we can track what needs saving the the DB later.

Parameters
$prop : string

Name of prop to set.

$value : mixed

Value of the prop.

Tags
since
Return values
mixed

get_changes()

Return data changes only.

public get_changes( ) : array
Tags
since
Return values
array

apply_changes()

Merge changes with data and clear.

public apply_changes( ) : mixed
Tags
since
Return values
mixed

get_hook_prefix()

Prefix for action and filter hooks on data.

protected get_hook_prefix( ) : string
Tags
since
Return values
string

get_prop()

Gets a prop for a getter method.

protected get_prop( $prop : string [, $context : string = 'view' ] ) : mixed

Gets the value from either current pending changes, or the data itself. Context controls what happens to the value before it's returned.

Parameters
$prop : string

Name of prop to get.

$context : string = 'view'

What the value is for. Valid values are view and edit.

Tags
since
Return values
mixed

set_date_prop()

Sets a date prop whilst handling formatting and datetime objects.

protected set_date_prop( $prop : string , $value : string|int ) : mixed
Parameters
$prop : string

Name of prop to set.

$value : string|int

Value of the prop.

Tags
since
Return values
mixed

error()

When invalid data is found, throw an exception unless reading from the DB.

protected error( $code : string , $message : string [, $http_status_code : int = 400 ] [, $data : array = array() ] ) : mixed
Parameters
$code : string

Error code.

$message : string

Error message.

$http_status_code : int = 400

HTTP status code.

$data : array = array()

Extra error data.

Tags
throws

Data Exception.

since
Return values
mixed
Back to the top