PHP Class Give_DB_Customers, Give

Since: 1.0
Inheritance: extends Give_DB
Mostrar archivo Open project: wordimpress/give Class Usage Examples

Public Methods

Method Description
__construct ( ) Class Constructor
add ( array $data = [] ) : int/bool Add a customer
attach_payment ( integer $customer_id, integer $payment_id ) : boolean Attaches a payment ID to a customer
count ( array $args = [] ) : integer Count the total number of customers in the database
create_table ( ) : void Create the table
decrement_stats ( integer $customer_id, float $amount ) : boolean Decrements customer purchase stats
delete ( boolean | string | integer $_id_or_email = false ) : boolean | integer Delete a customer
exists ( string $value = '', string $field = 'email' ) : boolean Checks if a customer exists
get_column_defaults ( ) : array Get default column values
get_columns ( ) : array Get columns and formats
get_customer_by ( string $field = 'id', mixed $value ) : mixed Retrieves a single customer from the database
get_customers ( array $args = [] ) : array | object | null Retrieve customers from the database
increment_stats ( integer $customer_id, float $amount ) : boolean Increments customer purchase stats
installed ( ) : boolean Check if the Customers table was ever installed
remove_payment ( integer $customer_id, integer $payment_id ) : boolean Removes a payment ID from a customer
update_customer_email_on_user_update ( integer $user_id, WP_User $old_user_data ) : boolean Updates the email address of a customer record when the email on a user is updated

Method Details

__construct() public method

Set up the Give DB Customer Class.
Since: 1.0
public __construct ( )

add() public method

Add a customer
Since: 1.0
public add ( array $data = [] ) : int/bool
$data array
return int/bool

attach_payment() public method

Attaches a payment ID to a customer
Since: 1.0
public attach_payment ( integer $customer_id, integer $payment_id ) : boolean
$customer_id integer Customer ID.
$payment_id integer Payment ID.
return boolean

count() public method

Count the total number of customers in the database
Since: 1.0
public count ( array $args = [] ) : integer
$args array
return integer Total number of customers.

create_table() public method

Create the table
Since: 1.0
public create_table ( ) : void
return void

decrement_stats() public method

Decrements customer purchase stats
Since: 1.0
public decrement_stats ( integer $customer_id, float $amount ) : boolean
$customer_id integer Customer ID.
$amount float Amount.
return boolean

delete() public method

NOTE: This should not be called directly as it does not make necessary changes to the payment meta and logs. Use give_customer_delete() instead.
Since: 1.0
public delete ( boolean | string | integer $_id_or_email = false ) : boolean | integer
$_id_or_email boolean | string | integer
return boolean | integer

exists() public method

Checks if a customer exists
Since: 1.0
public exists ( string $value = '', string $field = 'email' ) : boolean
$value string The value to search for. Default is empty.
$field string The Customer ID or email to search in. Default is 'email'.
return boolean True is exists, false otherwise.

get_column_defaults() public method

Get default column values
Since: 1.0
public get_column_defaults ( ) : array
return array Default column values.

get_columns() public method

Get columns and formats
Since: 1.0
public get_columns ( ) : array
return array Columns and formats.

get_customer_by() public method

Retrieves a single customer from the database
Since: 1.0
public get_customer_by ( string $field = 'id', mixed $value ) : mixed
$field string ID or email. Default is 'id'.
$value mixed The Customer ID or email to search. Default is 0.
return mixed Upon success, an object of the customer. Upon failure, NULL

get_customers() public method

Retrieve customers from the database
Since: 1.0
public get_customers ( array $args = [] ) : array | object | null
$args array
return array | object | null Customers array or object. Null if not found.

increment_stats() public method

Increments customer purchase stats
public increment_stats ( integer $customer_id, float $amount ) : boolean
$customer_id integer Customer ID.
$amount float Amoumt.
return boolean

installed() public method

Check if the Customers table was ever installed
Since: 1.4.3
public installed ( ) : boolean
return boolean Returns if the customers table was installed and upgrade routine run.

remove_payment() public method

Removes a payment ID from a customer
Since: 1.0
public remove_payment ( integer $customer_id, integer $payment_id ) : boolean
$customer_id integer Customer ID.
$payment_id integer Payment ID.
return boolean

update_customer_email_on_user_update() public method

Updates the email address of a customer record when the email on a user is updated
Since: 1.4.3
public update_customer_email_on_user_update ( integer $user_id, WP_User $old_user_data ) : boolean
$user_id integer User ID.
$old_user_data WP_User User data.
return boolean