PHP Class WC_Customer

Author: WooThemes
Inheritance: extends WC_Legacy_Customer
Afficher le fichier Open project: woocommerce/woocommerce Class Usage Examples

Protected Properties

Свойство Type Description
$calculated_shipping string Stores if user has calculated shipping in this session.
$data array Stores customer data.
$is_vat_exempt string Stores if user is VAT exempt for this session.
$password string Stores a password if this needs to be changed. Write-only and hidden from _data.

Méthodes publiques

Méthode Description
__construct ( WC_Customer | integer $data, boolean $is_session = false ) Load customer data based on how WC_Customer is called.
delete_and_reassign ( integer $reassign = null ) : boolean Delete a customer and reassign posts.
get_avatar_url ( ) : string Return this customer's avatar.
get_billing_address ( string $context = 'view' ) : string Get billing_address_1.
get_billing_address_1 ( string $context = 'view' ) : string Get billing_address_1.
get_billing_address_2 ( string $context = 'view' ) : string Get billing_address_2.
get_billing_city ( string $context = 'view' ) : string Get billing_city.
get_billing_company ( string $context = 'view' ) : string Get billing_company.
get_billing_country ( string $context = 'view' ) : string Get billing_country.
get_billing_email ( string $context = 'view' ) : string Get billing_email.
get_billing_first_name ( string $context = 'view' ) : string Get billing_first_name.
get_billing_last_name ( string $context = 'view' ) : string Get billing_last_name.
get_billing_phone ( string $context = 'view' ) : string Get billing_phone.
get_billing_postcode ( string $context = 'view' ) : string Get billing_postcode.
get_billing_state ( string $context = 'view' ) : string Get billing_state.
get_calculated_shipping ( ) : boolean Has customer calculated shipping?
get_date_created ( string $context = 'view' ) : integer Return the date this customer was created.
get_date_modified ( string $context = 'view' ) : integer Return the date this customer was last updated.
get_downloadable_products ( ) : array Gets a customer's downloadable products.
get_email ( string $context = 'view' ) : string Return the customer's email.
get_first_name ( string $context = 'view' ) : string Return customer's first name.
get_is_paying_customer ( string $context = 'view' ) : boolean Is the user a paying customer?
get_is_vat_exempt ( ) : boolean Get if customer is VAT exempt?
get_last_name ( string $context = 'view' ) : string Return customer's last name.
get_last_order ( ) : WC_Order | false Gets the customers last order.
get_order_count ( ) : integer Return the number of orders this customer has.
get_password ( ) : string Get password (only used when updating the user object).
get_role ( string $context = 'view' ) : string Return customer's user role.
get_shipping_address ( string $context = 'view' ) : string Get shipping_address_1.
get_shipping_address_1 ( string $context = 'view' ) : string Get shipping_address_1.
get_shipping_address_2 ( string $context = 'view' ) : string Get shipping_address_2.
get_shipping_city ( string $context = 'view' ) : string Get shipping_city.
get_shipping_company ( string $context = 'view' ) : string Get shipping_company.
get_shipping_country ( string $context = 'view' ) : string Get shipping_country.
get_shipping_first_name ( string $context = 'view' ) : string Get shipping_first_name.
get_shipping_last_name ( string $context = 'view' ) : string Get shipping_last_name.
get_shipping_postcode ( string $context = 'view' ) : string Get shipping_postcode.
get_shipping_state ( string $context = 'view' ) : string Get shipping_state.
get_taxable_address ( ) : array Get taxable address.
get_total_spent ( ) : float Return how much money this customer has spent.
get_username ( string $context = 'view' ) : string Return the customer's username.
has_calculated_shipping ( ) : boolean Has calculated shipping?
is_customer_outside_base ( ) : boolean Is customer outside base country (for tax purposes)?
is_vat_exempt ( ) : boolean Is customer VAT exempt?
set_billing_address ( string $value ) Set billing_address_1.
set_billing_address_1 ( string $value ) Set billing_address_1.
set_billing_address_2 ( string $value ) Set billing_address_2.
set_billing_address_to_base ( ) Set customer address to match shop base address.
set_billing_city ( string $value ) Set billing_city.
set_billing_company ( string $value ) Set billing_company.
set_billing_country ( string $value ) Set billing_country.
set_billing_email ( string $value ) Set billing_email.
set_billing_first_name ( string $value ) Set billing_first_name.
set_billing_last_name ( string $value ) Set billing_last_name.
set_billing_location ( string $country, string $state, string $postcode = '', string $city = '' ) Sets all address info at once.
set_billing_phone ( string $value ) Set billing_phone.
set_billing_postcode ( string $value ) Set billing_postcode.
set_billing_state ( string $value ) Set billing_state.
set_calculated_shipping ( boolean $calculated = true ) Calculated shipping?
set_date_created ( integer $timestamp ) Set the date this customer was last updated.
set_date_modified ( integer $timestamp ) Set the date this customer was last updated.
set_email ( string $value ) Set customer's email.
set_first_name ( string $first_name ) Set customer's first name.
set_is_paying_customer ( boolean $is_paying_customer ) Set if the user a paying customer.
set_is_vat_exempt ( boolean $is_vat_exempt ) Set if customer has tax exemption.
set_last_name ( string $last_name ) Set customer's last name.
set_password ( string $password ) Set customer's password.
set_role ( mixed $role ) Set customer's user role(s).
set_shipping_address ( string $value ) Set shipping_address_1.
set_shipping_address_1 ( string $value ) Set shipping_address_1.
set_shipping_address_2 ( string $value ) Set shipping_address_2.
set_shipping_address_to_base ( ) Set customer shipping address to base address.
set_shipping_city ( string $value ) Set shipping_city.
set_shipping_company ( string $value ) Set shipping_company.
set_shipping_country ( string $value ) Set shipping_country.
set_shipping_first_name ( string $value ) Set shipping_first_name.
set_shipping_last_name ( string $value ) Set shipping_last_name.
set_shipping_location ( string $country, string $state = '', string $postcode = '', string $city = '' ) Sets all shipping info at once.
set_shipping_postcode ( string $value ) Set shipping_postcode.
set_shipping_state ( string $value ) Set shipping_state.
set_username ( string $username ) Set customer's username.

Méthodes protégées

Méthode Description
get_address_prop ( string $prop, string $address = 'billing', string $context = 'view' ) : mixed Gets a prop for a getter method.
get_hook_prefix ( ) : string Prefix for action and filter hooks on data.
set_address_prop ( string $prop, string $address = 'billing', mixed $value ) Sets a prop for a setter method.

Method Details

__construct() public méthode

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.
public __construct ( WC_Customer | integer $data, boolean $is_session = false )
$data WC_Customer | integer Customer ID or data.
$is_session boolean True if this is the customer session

delete_and_reassign() public méthode

.
Since: 2.7.0
public delete_and_reassign ( integer $reassign = null ) : boolean
$reassign integer Reassign posts and links to new User ID.
Résultat boolean

get_address_prop() protected méthode

Gets a prop for a getter method.
Since: 2.7.0
protected get_address_prop ( string $prop, string $address = 'billing', string $context = 'view' ) : mixed
$prop string Name of prop to get.
$address string billing or shipping.
$context string What the value is for. Valid values are view and edit.
Résultat mixed

get_avatar_url() public méthode

Return this customer's avatar.
Since: 2.7.0
public get_avatar_url ( ) : string
Résultat string

get_billing_address() public méthode

Get billing_address_1.
public get_billing_address ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_address_1() public méthode

Get billing_address_1.
public get_billing_address_1 ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_address_2() public méthode

Get billing_address_2.
public get_billing_address_2 ( string $context = 'view' ) : string
$context string
Résultat string $value

get_billing_city() public méthode

Get billing_city.
public get_billing_city ( string $context = 'view' ) : string
$context string
Résultat string $value

get_billing_company() public méthode

Get billing_company.
public get_billing_company ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_country() public méthode

Get billing_country.
public get_billing_country ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_email() public méthode

Get billing_email.
public get_billing_email ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_first_name() public méthode

Get billing_first_name.
public get_billing_first_name ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_last_name() public méthode

Get billing_last_name.
public get_billing_last_name ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_phone() public méthode

Get billing_phone.
public get_billing_phone ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_postcode() public méthode

Get billing_postcode.
public get_billing_postcode ( string $context = 'view' ) : string
$context string
Résultat string

get_billing_state() public méthode

Get billing_state.
public get_billing_state ( string $context = 'view' ) : string
$context string
Résultat string

get_calculated_shipping() public méthode

Has customer calculated shipping?
public get_calculated_shipping ( ) : boolean
Résultat boolean

get_date_created() public méthode

Return the date this customer was created.
Since: 2.7.0
public get_date_created ( string $context = 'view' ) : integer
$context string
Résultat integer

get_date_modified() public méthode

Return the date this customer was last updated.
Since: 2.7.0
public get_date_modified ( string $context = 'view' ) : integer
$context string
Résultat integer

get_downloadable_products() public méthode

Gets a customer's downloadable products.
public get_downloadable_products ( ) : array
Résultat array Array of downloadable products

get_email() public méthode

Return the customer's email.
Since: 2.7.0
public get_email ( string $context = 'view' ) : string
$context string
Résultat string

get_first_name() public méthode

Return customer's first name.
Since: 2.7.0
public get_first_name ( string $context = 'view' ) : string
$context string
Résultat string

get_hook_prefix() protected méthode

Prefix for action and filter hooks on data.
Since: 2.7.0
protected get_hook_prefix ( ) : string
Résultat string

get_is_paying_customer() public méthode

Is the user a paying customer?
Since: 2.7.0
public get_is_paying_customer ( string $context = 'view' ) : boolean
$context string
Résultat boolean

get_is_vat_exempt() public méthode

Get if customer is VAT exempt?
Since: 2.7.0
public get_is_vat_exempt ( ) : boolean
Résultat boolean

get_last_name() public méthode

Return customer's last name.
Since: 2.7.0
public get_last_name ( string $context = 'view' ) : string
$context string
Résultat string

get_last_order() public méthode

Gets the customers last order.
public get_last_order ( ) : WC_Order | false
Résultat WC_Order | false

get_order_count() public méthode

Return the number of orders this customer has.
public get_order_count ( ) : integer
Résultat integer

get_password() public méthode

Get password (only used when updating the user object).
public get_password ( ) : string
Résultat string

get_role() public méthode

Return customer's user role.
Since: 2.7.0
public get_role ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_address() public méthode

Get shipping_address_1.
public get_shipping_address ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_address_1() public méthode

Get shipping_address_1.
public get_shipping_address_1 ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_address_2() public méthode

Get shipping_address_2.
public get_shipping_address_2 ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_city() public méthode

Get shipping_city.
public get_shipping_city ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_company() public méthode

Get shipping_company.
public get_shipping_company ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_country() public méthode

Get shipping_country.
public get_shipping_country ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_first_name() public méthode

Get shipping_first_name.
public get_shipping_first_name ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_last_name() public méthode

Get shipping_last_name.
public get_shipping_last_name ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_postcode() public méthode

Get shipping_postcode.
public get_shipping_postcode ( string $context = 'view' ) : string
$context string
Résultat string

get_shipping_state() public méthode

Get shipping_state.
public get_shipping_state ( string $context = 'view' ) : string
$context string
Résultat string

get_taxable_address() public méthode

Get taxable address.
public get_taxable_address ( ) : array
Résultat array

get_total_spent() public méthode

Return how much money this customer has spent.
public get_total_spent ( ) : float
Résultat float

get_username() public méthode

Return the customer's username.
Since: 2.7.0
public get_username ( string $context = 'view' ) : string
$context string
Résultat string

has_calculated_shipping() public méthode

Has calculated shipping?
public has_calculated_shipping ( ) : boolean
Résultat boolean

is_customer_outside_base() public méthode

Is customer outside base country (for tax purposes)?
public is_customer_outside_base ( ) : boolean
Résultat boolean

is_vat_exempt() public méthode

Is customer VAT exempt?
public is_vat_exempt ( ) : boolean
Résultat boolean

set_address_prop() protected méthode

Sets a prop for a setter method.
Since: 2.7.0
protected set_address_prop ( string $prop, string $address = 'billing', mixed $value )
$prop string Name of prop to set.
$address string Name of address to set. billing or shipping.
$value mixed Value of the prop.

set_billing_address() public méthode

Set billing_address_1.
public set_billing_address ( string $value )
$value string

set_billing_address_1() public méthode

Set billing_address_1.
public set_billing_address_1 ( string $value )
$value string

set_billing_address_2() public méthode

Set billing_address_2.
public set_billing_address_2 ( string $value )
$value string

set_billing_address_to_base() public méthode

Set customer address to match shop base address.
Since: 2.7.0

set_billing_city() public méthode

Set billing_city.
public set_billing_city ( string $value )
$value string

set_billing_company() public méthode

Set billing_company.
public set_billing_company ( string $value )
$value string

set_billing_country() public méthode

Set billing_country.
public set_billing_country ( string $value )
$value string

set_billing_email() public méthode

Set billing_email.
public set_billing_email ( string $value )
$value string

set_billing_first_name() public méthode

Set billing_first_name.
public set_billing_first_name ( string $value )
$value string

set_billing_last_name() public méthode

Set billing_last_name.
public set_billing_last_name ( string $value )
$value string

set_billing_location() public méthode

Sets all address info at once.
public set_billing_location ( string $country, string $state, string $postcode = '', string $city = '' )
$country string
$state string
$postcode string
$city string

set_billing_phone() public méthode

Set billing_phone.
public set_billing_phone ( string $value )
$value string

set_billing_postcode() public méthode

Set billing_postcode.
public set_billing_postcode ( string $value )
$value string

set_billing_state() public méthode

Set billing_state.
public set_billing_state ( string $value )
$value string

set_calculated_shipping() public méthode

Calculated shipping?
public set_calculated_shipping ( boolean $calculated = true )
$calculated boolean

set_date_created() public méthode

Set the date this customer was last updated.
Since: 2.7.0
public set_date_created ( integer $timestamp )
$timestamp integer

set_date_modified() public méthode

Set the date this customer was last updated.
Since: 2.7.0
public set_date_modified ( integer $timestamp )
$timestamp integer

set_email() public méthode

Set customer's email.
Since: 2.7.0
public set_email ( string $value )
$value string

set_first_name() public méthode

Set customer's first name.
Since: 2.7.0
public set_first_name ( string $first_name )
$first_name string

set_is_paying_customer() public méthode

Set if the user a paying customer.
Since: 2.7.0
public set_is_paying_customer ( boolean $is_paying_customer )
$is_paying_customer boolean

set_is_vat_exempt() public méthode

Set if customer has tax exemption.
public set_is_vat_exempt ( boolean $is_vat_exempt )
$is_vat_exempt boolean

set_last_name() public méthode

Set customer's last name.
Since: 2.7.0
public set_last_name ( string $last_name )
$last_name string

set_password() public méthode

Set customer's password.
Since: 2.7.0
public set_password ( string $password )
$password string

set_role() public méthode

Set customer's user role(s).
Since: 2.7.0
public set_role ( mixed $role )
$role mixed

set_shipping_address() public méthode

Set shipping_address_1.
public set_shipping_address ( string $value )
$value string

set_shipping_address_1() public méthode

Set shipping_address_1.
public set_shipping_address_1 ( string $value )
$value string

set_shipping_address_2() public méthode

Set shipping_address_2.
public set_shipping_address_2 ( string $value )
$value string

set_shipping_address_to_base() public méthode

Set customer shipping address to base address.
Since: 2.7.0

set_shipping_city() public méthode

Set shipping_city.
public set_shipping_city ( string $value )
$value string

set_shipping_company() public méthode

Set shipping_company.
public set_shipping_company ( string $value )
$value string

set_shipping_country() public méthode

Set shipping_country.
public set_shipping_country ( string $value )
$value string

set_shipping_first_name() public méthode

Set shipping_first_name.
public set_shipping_first_name ( string $value )
$value string

set_shipping_last_name() public méthode

Set shipping_last_name.
public set_shipping_last_name ( string $value )
$value string

set_shipping_location() public méthode

Sets all shipping info at once.
public set_shipping_location ( string $country, string $state = '', string $postcode = '', string $city = '' )
$country string
$state string
$postcode string
$city string

set_shipping_postcode() public méthode

Set shipping_postcode.
public set_shipping_postcode ( string $value )
$value string

set_shipping_state() public méthode

Set shipping_state.
public set_shipping_state ( string $value )
$value string

set_username() public méthode

Set customer's username.
Since: 2.7.0
public set_username ( string $username )
$username string

Property Details

$calculated_shipping protected_oe property

Stores if user has calculated shipping in this session.
protected string $calculated_shipping
Résultat string

$data protected_oe property

Stores customer data.
protected array $data
Résultat array

$is_vat_exempt protected_oe property

Stores if user is VAT exempt for this session.
protected string $is_vat_exempt
Résultat string

$password protected_oe property

Stores a password if this needs to be changed. Write-only and hidden from _data.
protected string $password
Résultat string