PHP Класс Give_Customer, Give

This class handles customers.
С версии: 1.0
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$date_created string The customer's creation date
$email string The customer's email
$id integer The customer ID
$name string The customer's name
$notes string Customer Notes
$payment_ids array The payment IDs associated with the customer
$purchase_count integer The customer's purchase count
$purchase_value integer The customer's lifetime value
$user_id integer The user ID associated with the customer

Защищенные свойства (Protected)

Свойство Тип Описание
$db Give_DB_Customers The Database Abstraction

Открытые методы

Метод Описание
__construct ( boolean $_id_or_email = false, boolean $by_user_id = false ) Class Constructor
__get ( $key ) Magic __get function to dispatch a call to retrieve a private property.
add_meta ( string $meta_key = '', mixed $meta_value, boolean $unique = false ) : boolean Add meta data field to a customer.
add_note ( string $note = '' ) : string | boolean Add a note for the customer.
attach_payment ( integer $payment_id, boolean $update_stats = true ) : boolean Attach Payment
create ( array $data = [] ) : mixed Creates a customer
decrease_purchase_count ( integer $count = 1 ) : mixed Decrease the customer purchase count.
decrease_value ( float $value ) : mixed Decrease a customer's lifetime value.
delete_meta ( string $meta_key = '', mixed $meta_value = '' ) : boolean Remove metadata matching criteria from a customer.
get_meta ( string $meta_key = '', boolean $single = true ) : mixed Retrieve customer meta field for a customer.
get_notes ( integer $length = 20, integer $paged = 1 ) : array Get the parsed notes for a customer as an array.
get_notes_count ( ) : integer Get the total number of notes we have after parsing.
increase_purchase_count ( integer $count = 1 ) : integer Increase the purchase count of a customer.
increase_value ( float $value ) : mixed Increase the customer's lifetime value.
remove_payment ( integer $payment_id, boolean $update_stats = true ) : boolean Remove Payment
update ( array $data = [] ) : boolean Update a customer record
update_donation_value ( float $curr_amount, float $new_amount ) : mixed Decrease/Increase a customer's lifetime value.
update_meta ( string $meta_key = '', mixed $meta_value, mixed $prev_value = '' ) : boolean Update customer meta field based on customer ID.

Приватные методы

Метод Описание
get_raw_notes ( ) : string Get the notes column for the customer
sanitize_columns ( array $data ) : array Sanitize the data for update/create
setup_customer ( object $customer ) : boolean Setup Customer

Описание методов

__construct() публичный Метод

Set up the Give Customer Class.
С версии: 1.0
public __construct ( boolean $_id_or_email = false, boolean $by_user_id = false )
$_id_or_email boolean
$by_user_id boolean

__get() публичный Метод

Magic __get function to dispatch a call to retrieve a private property.
С версии: 1.0
public __get ( $key )

add_meta() публичный Метод

Add meta data field to a customer.
С версии: 1.6
public add_meta ( string $meta_key = '', mixed $meta_value, boolean $unique = false ) : boolean
$meta_key string Metadata name. Default is empty.
$meta_value mixed Metadata value.
$unique boolean Optional. Whether the same key should not be added. Default is false.
Результат boolean False for failure. True for success.

add_note() публичный Метод

Add a note for the customer.
С версии: 1.0
public add_note ( string $note = '' ) : string | boolean
$note string The note to add. Default is empty.
Результат string | boolean The new note if added successfully, false otherwise.

attach_payment() публичный Метод

Attach payment to the customer then triggers increasing stats.
С версии: 1.0
public attach_payment ( integer $payment_id, boolean $update_stats = true ) : boolean
$payment_id integer The payment ID to attach to the customer.
$update_stats boolean For backwards compatibility, if we should increase the stats or not.
Результат boolean If the attachment was successfuly.

create() публичный Метод

Creates a customer
С версии: 1.0
public create ( array $data = [] ) : mixed
$data array Array of attributes for a customer.
Результат mixed False if not a valid creation, Customer ID if user is found or valid creation.

decrease_purchase_count() публичный Метод

Decrease the customer purchase count.
С версии: 1.0
public decrease_purchase_count ( integer $count = 1 ) : mixed
$count integer The amount to decrease by.
Результат mixed If successful, the new count, otherwise false.

decrease_value() публичный Метод

Decrease a customer's lifetime value.
С версии: 1.0
public decrease_value ( float $value ) : mixed
$value float The value to decrease by.
Результат mixed If successful, the new value, otherwise false.

delete_meta() публичный Метод

Remove metadata matching criteria from a customer.
С версии: 1.6
public delete_meta ( string $meta_key = '', mixed $meta_value = '' ) : boolean
$meta_key string Metadata name. Default is empty.
$meta_value mixed Optional. Metadata value. Default is empty.
Результат boolean False for failure. True for success.

get_meta() публичный Метод

Retrieve customer meta field for a customer.
С версии: 1.6
public get_meta ( string $meta_key = '', boolean $single = true ) : mixed
$meta_key string The meta key to retrieve. Default is empty.
$single boolean Whether to return a single value. Default is true.
Результат mixed Will be an array if $single is false. Will be value of meta data field if $single is true.

get_notes() публичный Метод

Get the parsed notes for a customer as an array.
С версии: 1.0
public get_notes ( integer $length = 20, integer $paged = 1 ) : array
$length integer The number of notes to get.
$paged integer What note to start at.
Результат array The notes requested.

get_notes_count() публичный Метод

Get the total number of notes we have after parsing.
С версии: 1.0
public get_notes_count ( ) : integer
Результат integer The number of notes for the customer.

increase_purchase_count() публичный Метод

Increase the purchase count of a customer.
С версии: 1.0
public increase_purchase_count ( integer $count = 1 ) : integer
$count integer The number to increment by.
Результат integer The purchase count.

increase_value() публичный Метод

Increase the customer's lifetime value.
С версии: 1.0
public increase_value ( float $value ) : mixed
$value float The value to increase by.
Результат mixed If successful, the new value, otherwise false.

remove_payment() публичный Метод

Remove a payment from this customer, then triggers reducing stats.
С версии: 1.0
public remove_payment ( integer $payment_id, boolean $update_stats = true ) : boolean
$payment_id integer The Payment ID to remove.
$update_stats boolean For backwards compatibility, if we should increase the stats or not.
Результат boolean If the removal was successful.

update() публичный Метод

Update a customer record
С версии: 1.0
public update ( array $data = [] ) : boolean
$data array Array of data attributes for a customer (checked via whitelist).
Результат boolean If the update was successful or not.

update_donation_value() публичный Метод

This function will update donation stat on basis of current amount and new amount donation difference. Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat.
С версии: 1.0
public update_donation_value ( float $curr_amount, float $new_amount ) : mixed
$curr_amount float Current Donation amount.
$new_amount float New (changed) Donation amount.
Результат mixed If successful, the new donation stat value, otherwise false.

update_meta() публичный Метод

Update customer meta field based on customer ID.
С версии: 1.6
public update_meta ( string $meta_key = '', mixed $meta_value, mixed $prev_value = '' ) : boolean
$meta_key string Metadata key. Default is empty.
$meta_value mixed Metadata value.
$prev_value mixed Optional. Previous value to check before removing. Default is empty.
Результат boolean False on failure, true if success.

Описание свойств

$date_created публичное свойство

The customer's creation date
С версии: 1.0
public string $date_created
Результат string

$db защищенное свойство

The Database Abstraction
С версии: 1.0
protected Give_DB_Customers $db
Результат Give_DB_Customers

$email публичное свойство

The customer's email
С версии: 1.0
public string $email
Результат string

$id публичное свойство

The customer ID
С версии: 1.0
public int $id
Результат integer

$name публичное свойство

The customer's name
С версии: 1.0
public string $name
Результат string

$notes публичное свойство

Customer Notes
С версии: 1.0
public string $notes
Результат string

$payment_ids публичное свойство

The payment IDs associated with the customer
С версии: 1.0
public array $payment_ids
Результат array

$purchase_count публичное свойство

The customer's purchase count
С версии: 1.0
public int $purchase_count
Результат integer

$purchase_value публичное свойство

The customer's lifetime value
С версии: 1.0
public int $purchase_value
Результат integer

$user_id публичное свойство

The user ID associated with the customer
С версии: 1.0
public int $user_id
Результат integer