miniCal
Search
K

Customer Helper Functions

The helper you can use to create, delete, get and update Customer details.

function add_customer($customer) {.....}

Supported hooks

Filter name: before_add_customer Description: This filter would be executed before add customer into the database in add_customer helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_add_customer’, ‘before_add_customer_callback_fun’, 10, 1 );
function before_add_customer_callback_fun($customer) {
// code
}
Filter name: should_add_customer Description: This filter would be executed before add customer into database in add_customer helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_add_customer’, ‘should_add_customer_callback_fun’, 10, 1 );
function should_add_customer_callback_fun($customer) {
// code
}
hook name: pre.add.customer Description: This hook would be executed before add customer into the database in add_customer helper. Usage:
// The filter callback function is based on the filter.
add_action('pre.add.customer', 'pre_add_customer_callback_fun', 10, 1);
function pre_add_customer_callback_fun($customer) {
// code
}
hook name: post.add.customer Description: This hook would be executed after add customer into the database in add_customer helper. Usage:
// The filter callback function is based on the filter.
add_action('post.add.customer', 'post_add_customer_callback_fun', 10, 1);
function post_add_customer_callback_fun($customer) {
// code
}
Usage
// for use customer helper you need to add this helper on controller or
// you can autoload this helper.
$this->load->helper('includes/customer');
// add a new customer in customer table. And add customer's primary card details.
$customer_id = add_customer($customer);
Request Parameters
Parameters in array format includes following attributes:
Param
Type
Required
Default
Description
customer_name
Character
Yes
Null
The customer name of a specific customer.
address
Character
Null
The address for specific customer.
city
Character
Null
The city for a specific customer.
region
Character
Null
The region for a specific customer.
country
Character
Null
The country for a specific customer.
postal_code
Character
Null
The postal_code for a specific customer.
phone
Character
Null
The phone number of a specific customer.
fax
Character
Null
The fax for a specific customer.
email
Character
Null
The email id of specific customer.
company_id
Integer
Yes
Null
The company_id for specific customer.
customer_notes
Character
Null
The customer_notes for a specific customer.
phone2
Character
Null
The phone2 second number of a specific customer.
address2
Character
Null
The address2 second address of a specific customer.
customer_type
Character
Null
The customer_type for a specific customer.
is_primary
Integer
Yes
1
The is_primary if active then customer card add as a primary card for a specific customer.
card_name
Character
Yes
Null
The card_name for a specific customer card details.
cc_number
Character
Yes
Null
The cc_number of the card for customer card details.
cvc
Character
Yes
Null
The cvc of the card for customer card details.
cc_expiry_month
Character
Yes
Null
The cc_expiry_month of the card for customer card details.
cc_expiry_year
Character
Yes
Null
The cc_expiry_year of the card for customer card details.
Response
Response includes the following attributes:
if data have been added successfully it would return the key of specific customer id.
return $customer_id;
if data does not add it will return null.

function get_customer($customer_id) {....}

Supported hooks

Filter name: before_get_customer Description: This filter would be executed before retrieving customer details from database in get_customer helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_get_customer’, ‘before_get_customer_callback_fun’, 10, 1 );
function before_get_customer_callback_fun($customer_id) {
// code
}
Filter name: should_get_customer Description: This filter would be executed before retrieving customer details from database in get_customer helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_get_customer’, ‘should_get_customer_callback_fun’, 10, 1 );
function should_get_customer_callback_fun($customer_id) {
// code
}
hook name: pre.get.customer Description: This hook would be executed before retrieving customer details from database in get_customer helper. Usage:
// The filter callback function is based on the filter.
add_action('pre.get.customer', 'pre_get_customer_callback_fun', 10, 1);
function pre_get_customer_callback_fun($customer_id) {
// code
}
hook name: post.get.customer Description: This hook would be executed after retrieving customer details from database in get_customer helper. Usage:
// The filter callback function is based on the filter.
add_action('post.get.customer', 'post_get_customer_callback_fun', 10, 1);
function post_get_customer_callback_fun($customer_id) {
// code
}
Usage
// Retrieves customer data based on a customer_id.
$customer_data = get_customer($customer_id);
Request Parameters
Param
Type
Required
Default
Description
$customer_id
Integer
Yes
Null
The primary id of the customer corresponds to the customer table
Response
// Successfully response giving you array of customer data.
Array
(
[customer_id] => 21
[customer_name] => vishal solanki
[address] => 162 banganga
[city] => indore
[region] =>
[country] => india
[postal_code] => 452007
[phone] => 45435656657
[fax] =>
[email] =>
[company_id] => 1
[customer_notes] =>
[is_deleted] => 0
[customer_type] =>
[cc_number] =>
[cc_expiry_month] =>
[cc_expiry_year] =>
[stripe_customer_id] =>
[customer_type_id] => 1
[address2] =>
[phone2] => 36546667667
[cc_tokenex_token] =>
[cc_cvc_encrypted] =>
[customer_fields] => Array
(
)
)
//if there is no customer data for any customer id provided in input or any error will return null.

function get_customers($filter) {.....}

Supported hooks
Filter name: before_get_customers Description: This filter would be executed before retrieving customer details from database in get_customers helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_get_customers’, ‘before_get_customers_callback_fun’, 10, 1 );
function before_get_customers_callback_fun($filter) {
// code
}
Filter name: should_get_customers Description: This filter would be executed before retrieving customer details from database in get_customers helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_get_customers’, ‘should_get_customers_callback_fun’, 10, 1 );
function should_get_customers_callback_fun($filter) {
// code
}
hook name: pre.get.customers Description: This hook would be executed before retrieving customer details from database in get_customers helper. Usage:
// The filter callback function is based on the filter.
add_action('pre.get.customers', 'pre_get_customers_callback_fun', 10, 1);
function pre_get_customers_callback_fun($filter) {
// code
}
hook name: post.get.customers Description: This hook would be executed after retrieving customer details from database in get_customers helper. Usage:
// The filter callback function is based on the filter.
add_action('post.get.customers', 'post_get_customers_callback_fun', 10, 1);
function post_get_customers_callback_fun($filter) {
// code
}
Usage
// Retrieves customer data based on a filter array.
$customer_data = get_customers($filter);
Request Parameters
parameter array filter required for payment details.
Param
Type
Required
Default
Description
customer_name
Character
Yes
Null
The customer name for a specific customer details.
customer_id
Integer
Yes
Null
The customer_id for a specific customer.
company_id
Integer
Yes
Null
The company_id for a specific customer.
email
Character
Yes
Null
The email for a specific customer.
Response
// $response array includes following attributes:
// $response['customer_name'] : the customer_name of specific customer.
// $response['address'] : the address for specific customer .
// $response['city'] : the is_percentage for specific customer.
// $response['region'] : the region for specific customer.
// $response['country'] : the country for specific customer.
// $response['postal_code'] : the postal_code for specific customer.
// $response['phone'] : the phone for specific customer.
// $response['fax'] : the fax for specific customer.
// $response['email'] : the email for specific customer.
// $response['customer_notes'] : the customer_notes for specific customer.
// $response['customer_type'] : the customer_type for specific customer.
// $response['address2'] : the customer_notes for specific customer.
// $response['phone2'] : the customer_notes for specific customer.
// $response['is_primary'] : the is_primary for specific customer card details.
// $response['card_name'] : the card_name for specific customer card details.
// $response['cc_number'] : the cc_number for specific customer card details.
// $response['cvc'] : the cvc for specific customer card details.
// $response['cc_expiry_month'] : the cc_expiry_month for specific customer card details.
// $response['cc_expiry_year'] : the cc_expiry_year for specific customer card details.
// and many more attributes for table customer and join with customer card details .
// Successfully response giving you array of customer data.
Array
(
[0] => Array
(
[customer_id] => 21
[customer_name] => vishal solanki
[address] => 162 banganga
[city] => indore
[region] =>
[country] => india
[postal_code] => 452007
[phone] => 45435656657
[fax] =>
[email] =>
[company_id] => 1
[customer_notes] =>
[is_deleted] => 0
[customer_type] =>
[cc_number] =>
[cc_expiry_month] =>
[cc_expiry_year] =>
[stripe_customer_id] =>
[customer_type_id] => 1
[address2] =>
[phone2] => 36546667667
[cc_tokenex_token] =>
[cc_cvc_encrypted] =>
[id] => 6
[is_primary] => 1
[evc_card_status] =>
[card_name] =>
[is_card_deleted] => 0
[customer_meta_data] =>
)
)
//If there is no customer data for filter provided in input or any error will return null.

function update_customers($customer, $customer_id) {....}

Usage
//update customer data based on a update data and customer id.
update_customer($customer, $customer_id);
Supported hooks
Filter name: before_update_customer Description: This filter would be executed before update customer into the database in update_customer helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘before_update_customer’, ‘before_update_customer_callback_fun’, 10, 1 );
function before_update_customer_callback_fun($customer, $customer_id) {
// code
}
Filter name: should_update_customer Description: This filter would be executed before update rate into database in update_rates helper. Usage:
// The filter callback function is based on the filter.
add_filter( ‘should_update_customer’, ‘should_update_customer_callback_fun’, 10, 1 );
function should_update_customer_callback_fun($customer, $customer_id) {
// code
}
hook name: pre.update.customer Description: This hook would be executed before update customer into the database in update_customer helper. Usage:
// The filter callback function is based on the filter.
add_action('pre.update.customer', 'pre_update_customer_callback_fun', 10, 1);
function pre_update_customer_callback_fun($customer, $customer_id) {
//code
}
hook name: post.update.customer Description: This hook would be executed after update customer into the database in update_customer helper. Usage:
// The filter callback function is based on the filter.
add_action('post.update.customer', 'post_update_customer_callback_fun', 10, 1);
function post_update_customer_callback_fun($customer, $customer_id) {
// code
}
Request Parameters
Request required customer_id and array format data includes following attributes:
Param
Type
Required
Default
Description
customer_name
Character
Yes
Null
The customer name of a specific customer.
address
Character
Null
The address for specific customer.
city
Character
Null
The city for a specific customer.
region
Character
Null
The region for a specific customer.
country
Character
Null
The country for a specific customer.
postal_code
Character
Null
The postal_code for a specific customer.
phone
Character
Null
The phone number of a specific customer.
fax
Character
Null
The fax for a specific customer.
email
Character
Null
The email id of specific customer.
customer_notes
Character
Null
The customer_notes for a specific customer.
phone2
Character
Null
The phone2 second number of a specific customer.
address2
Character
Null
The address2 second address of a specific customer.
customer_type
Character
Null
The customer_type for a specific customer.
Response
Response return mixed Either true or null if customer data is updated then true else null.

function delete_customer($customer_id) {.....}

Usage
// delete a customer data from the customer table. it's a soft delete process only status will change data still existing in the backend database.
delete_customer($customer_id);
Request Parameters
Param
Type
Required
Default
Description
$customer_id
Integer
Yes
Null
The id of the customer corresponds to the customer table
Response
Response return mixed Either true or null if customer data is deleted then true
else null.