Rates Helper Functions

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

function add_rates($rates) {.....}

Supported hooks

Filter name: before_add_rates Description: This filter would be executed before add rate into the database in add_rates helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘before_add_rates’, ‘before_add_rates_callback_fun’, 10, 1 );

function before_add_rates_callback_fun($rates) {
 // code
}

Filter name: should_add_rates Description: This filter would be executed before add rate into database in add_rates helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘should_add_rates’, ‘should_add_rates_callback_fun’, 10, 1 );

function should_add_rates_callback_fun($rates) {
    // code
}

hook name: pre.add.rates Description: This hook would be executed before add rate into the database in add_rates helper. Usage:

// The filter callback function is based on the filter.

add_action('pre.add.rates', 'pre_add_rates_callback_fun', 10, 1);

function pre_add_rates_callback_fun($rates) {
    // code
}

hook name: post.add.rates Description: This hook would be executed after add rate into the database in add_rates helper. Usage:

// The filter callback function is based on the filter.

add_action('post.add.rates', 'post_add_rates_callback_fun', 10, 1);

function post_add_rates_callback_fun($rates) {
    // code
}

Usage

// for use rates helper you need to add this helper on controller or
// you can autoload this helper.
$this->load->helper('includes/rates');

// add a new rate in rates table.
$rate_id = add_rates($rates);

Request Parameters

Parameters in array format includes following attributes:

Response

Response include following attributes:
if data have added successfully it would return the key of specific rate id.
retrun $rate_id;
if data does not add it will return null.

function get_rate($rate_id) {....}

Supported hooks

Filter name: before_get_rate Description: This filter would be executed before retrieving rate details from database in get_rate helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘before_get_rate’, ‘before_get_rate_callback_fun’, 10, 1 );

function before_get_rate_callback_fun($rate_id) {
 // code
}

Filter name: should_get_rate Description: This filter would be executed before retrieving rate details from database in get_rate helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘should_get_rate’, ‘should_get_rate_callback_fun’, 10, 1 );

function should_get_rate_callback_fun($rate_id) {
    // code
}

hook name: pre.get.rate Description: This hook would be executed before retrieving rate details from database in get_rate helper. Usage:

// The filter callback function is based on the filter.

add_action('pre.get.rate', 'pre_get_rate_callback_fun', 10, 1);

function pre_get_rate_callback_fun($rate_id) {
    // code
}

hook name: post.get.rate Description: This hook would be executed after retrieving rate details from database in get_rate helper. Usage:

// The filter callback function is based on the filter.

add_action('post.get.rate', 'post_get_rate_callback_fun', 10, 1);

function post_get_rate_callback_fun($rate_id) {
    // code
}

Usage

// Retrieves rate data based on a rate_id.
$rate_data = get_rate($rate_id);

Request Parameters

Response

// $response array includes following attributes:
// $response['rate_plan_id'] : the rate_plan_id of specific rate.
// $response['base_rate'] : the base_rate for specific rate.
// $response['adult_1_rate'] : the adult_1_rate for specific rate.
// $response['adult_2_rate'] : the adult_2_rate for specific rate.
// $response['adult_3_rate'] : the adult_3_rate for specific rate.
// $response['adult_4_rate'] : the adult_4_rate for specific rate.
// $response['additional_adult_rate'] : the additional_adult_rate for specific rate.
// $response['minimum_length_of_stay'] : the minimum_length_of_stay for specific rate.
// $response['closed_to_arrival'] : the closed_to_arrival  for specific rate.
// $response['closed_to_departure'] : the closed_to_departure for specific rate.
// and many more attributes for table rate with rate table.
 
// Successfully response giving an array of rate data.

  Array
  (
    [rate_id] => 2
    [rate_plan_id] => 2
    [base_rate] => 
    [adult_1_rate] => 
    [adult_2_rate] => 
    [adult_3_rate] => 
    [adult_4_rate] => 
    [additional_adult_rate] => 
    [additional_child_rate] => 
    [is_deleted] => 
    [minimum_length_of_stay] => 
    [maximum_length_of_stay] => 
    [minimum_length_of_stay_arrival] => 
    [maximum_length_of_stay_arrival] => 
    [closed_to_arrival] => 
    [closed_to_departure] => 
    [can_be_sold_online] => 1
   )
   
// If there is no rate data for any rate id provided in input or any error will return null. 

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

Supported hooks

Filter name: before_get_rates Description: This filter would be executed before retrieving rate details from database in get_rates helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘before_get_rates’, ‘before_get_rates_callback_fun’, 10, 1 );

function before_get_rates_callback_fun($filter) {
 // code
}

Filter name: should_get_rates Description: This filter would be executed before retrieving rate details from database in get_rates helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘should_get_rates’, ‘should_get_rates_callback_fun’, 10, 1 );

function should_get_rates_callback_fun($filter) {
    // code
}

hook name: pre.get.rates Description: This hook would be executed before retrieving rate details from database in get_rates helper. Usage:

// The filter callback function is based on the filter.

add_action('pre.get.rates', 'pre_get_rates_callback_fun', 10, 1);

function pre_get_rates_callback_fun($filter) {
    // code
}

hook name: post.get.rates Description: This hook would be executed after retrieving rate details from database in get_rates helper. Usage:

// The filter callback function is based on the filter.

add_action('post.get.rates', 'post_get_rates_callback_fun', 10, 1);

function post_get_rates_callback_fun($filter) {
    // code
}

Usage


// Retrieves rate data based on a filter array.
$rate_data = get_rates($filter);

Request Parameters

parameter array filter required for rate details.

Response

// $response array includes following attributes:
// $response['rate_plan_id'] : the rate_plan_id of specific rate.
// $response['base_rate'] : the base_rate for specific rate.
// $response['adult_1_rate'] : the adult_1_rate for specific rate.
// $response['adult_2_rate'] : the adult_2_rate for specific rate.
// $response['adult_3_rate'] : the adult_3_rate for specific rate.
// $response['adult_4_rate'] : the adult_4_rate for specific rate.
// $response['additional_adult_rate'] : the additional_adult_rate for specific rate.
// $response['minimum_length_of_stay'] : the minimum_length_of_stay for specific rate.
// $response['closed_to_arrival'] : the closed_to_arrival  for specific rate.
// $response['closed_to_departure'] : the closed_to_departure for specific rate.

// Successfully response giving you array of rate data.
  Array
(
    [0] => Array
        (
            [rate_id] => 3
            [rate_plan_id] => 1
            [base_rate] => 
            [adult_1_rate] => 20.00
            [adult_2_rate] => 40.00
            [adult_3_rate] => 60.00
            [adult_4_rate] => 80.00
            [additional_adult_rate] => 
            [additional_child_rate] => 
            [is_deleted] => 
            [minimum_length_of_stay] => 
            [maximum_length_of_stay] => 
            [minimum_length_of_stay_arrival] => 
            [maximum_length_of_stay_arrival] => 
            [closed_to_arrival] => 0
            [closed_to_departure] => 0
            [can_be_sold_online] => 1
        )
)

// if there is no rate data for filter provided in input or any error will return null.

function update_rates($rates , $rate_id) {....}

Usage

//update rate data based on a update data and rate id.
 update_rates($rates , $rate_id);

Supported hooks

Filter name: before_update_rates Description: This filter would be executed before update rate into the database in update_rates helper. Usage:

// The filter callback function is based on the filter.

add_filter( ‘before_update_rates’, ‘before_update_rates_callback_fun’, 10, 1 );

function before_update_rates_callback_fun($rates , $rate_id) {
 // code
}

Filter name: should_update_rates 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_rates’, ‘should_update_rates_callback_fun’, 10, 1 );

function should_update_rates_callback_fun($rates, $rate_id) {
    // code
}

hook name: pre.update.rates Description: This hook would be executed before update rate into the database in update_rates helper. Usage:

// The filter callback function is based on the filter.

add_action('pre.update.rates', 'pre_update_rates_callback_fun', 10, 1);

function pre_update_rates_callback_fun($rates, $rate_id) {
    // code
}

hook name: post.update.rates Description: This hook would be executed after update rate into the database in update_rates helper. Usage:

// The filter callback function is based on the filter.

add_action('post.update.rates', 'post_update_rates_callback_fun', 10, 1);

function post_update_rates_callback_fun($rates, $rate_id) {
    // code
}

Request Parameters

Request required rate_id and array format data includes following attributes:

Response

Response return mixed Either true or null if rate data is updated then true else null.

function delete_rate($rate_id) {.....}

Usage

// delete a rate data from the rates table. it's a soft delete process only status will change data still existing in the backend database.

 delete_rate($rate_id);

Request Parameters

Response

Response return mixed Either true or null if rate data is deleted then true 
else null.

Last updated