Search the site:

Home / WooCommerce Booking Appointment Plugin Hooks Filters

WooCommerce Booking Appointment Plugin Hooks Filters

Hooks:

Admin Settings:

Use the below hooks to add new fields at appropriate places within the Booking meta box on each product page in admin.

bkap_before_enable_booking: Use this hook to add new field/s before the “Enable Booking Date” checkbox on the product page.

Present in file: booking-box.php

Usage:

<?php 
add_action('bkap_before_enable_booking','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_enable_booking','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_enable_multiple_days: Use this hook to add new field/s before the “Allow Multiple Day Booking” checkbox on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_enable_multiple_days','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_enable_multiple_days','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_booking_method_select: Use this hook to add new field/s before the “Select Booking Method” checkboxes on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_booking_method_select','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_booking_method_select','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_minimum_days: Use this hook to add new field/s before the “Advance Booking Period” field on the admin product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_minimum_days','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_minimum_days','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_number_of_dates: Use this hook to add new field/s before the “Number of Dates to choose” textbox on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_number_of_dates','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_number_of_dates','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_purchase_without_date: Use this hook to add new field/s before the “Purchase without choosing a date” checkbox on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_purchase_without_date','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_purchase_without_date','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_product_holidays: Use this hook to add new field/s before the “Holidays” textarea on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_product_holidays','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_product_holidays','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_enable_time: Use this hook to add new field/s before the “Enable Booking Time” checkbox on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_enable_time','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_enable_time','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_after_time_enabled: Use this hook to add new field/s after the “Enable Booking Time’ checkbox on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_after_time_enabled','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_after_time_enabled','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_after_lockout_time: Use this hook to add new field/s after the “Lockout” field in the time slot div on the admin product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_after_lockout_time','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_after_lockout_time','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_range_selection_radio: Use this hook to add a new field before the ‘Booking Type’ radio button on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_range_selection_radio','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_range_selection_radio','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_booking_start_date_range: Use this hook to add a new field before the ‘Bookings Start on’ date field on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_booking_start_date_range','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_booking_start_date_range','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_before_booking_end_date_range: Use this hook to add a new field before the ‘Bookings End on’ date field on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_before_booking_end_date_range','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_before_booking_end_date_range','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_add_column_names: Use this hook to add new column on the View/Delete Date and Time Slots tab for Recurring and Specific day settings on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_add_column_names','add_new_input',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_add_column_names','add_new_input',10,1);
function add_new_input($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);
?>
<th> Custom Column </th>
<?php
....			
}

bkap_add_tabs: Use this hook to add a new tab in the Booking Box on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_add_tabs','add_new_tab',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_add_tabs','add_new_tab',10,1);
function add_new_tab( $product_id ){
?>
<li><a id="new_tab"> <?php _e( 'New Tab', 'woocommerce-booking' ); ?> </a></li>
<?php
....
}

bkap_after_listing_enabled: Use this hook to add fields in the new tab in the Booking Box ( added using bkap_add_tab ) on the product page.

Present in file: booking-box.php

Usage:

<?php
add_action('bkap_after_listing_enabled','add_new_tab_fields',10,1);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_after_listing_enabled','add_new_tab_fields',10,1);
function add_new_tab_fields( $product_id ){
?>
<label for="test_field">Test Field</label>

<input type="checkbox" name="test_field" id="test_field" value="yes" ></input>
<?php
....
}

bkap_add_global_settings_tab: Use this hook to add a new tab in the Booking->Settings menu.

Present in file: global-menu.php

Usage:

<?php
add_action( 'bkap_add_global_settings_tab','add_global_tab' );
?>

Parameters: None

Example:

<?php
add_action( 'bkap_add_global_settings_tab', 'add_global_tab' );
function add_global_tab() {
?>
<a href="admin.php?page=woocommerce_booking_page&action=new_global_tab" class="nav-tab nav-tab-active"> <?php _e( 'New Global Tab', 'woocommerce-booking' );?> </a>
<?php
....
}

bkap_after_global_holiday_field: Use this hook to add a setting in the Booking->Settings menu Global Booking Settings tab after the Global holiday setting.

Present in file: global-menu.php

Usage:

<?php
add_action('bkap_after_global_holiday_field','add_new_input');
?>

Parameters:None

Example:

<?php
add_action('bkap_after_global_holiday_field','add_new_input');
function add_new_input(){
?>
<tr>
<th>
<label>Custom field:</label>
</th>
<td>
<input type="text" name="booking_addon_setting" id="booking_addon_setting" value="" />
</td>
</tr>
<?php
....
}

bkap_add_submenu: Use this hook to add a new submenu in the Booking menu.

Present in file: global-menu.php

Usage:

<?php
add_action('bkap_add_submenu','add_new_menu');
?>

Parameters:None

Example:

<?php
add_action('bkap_add_submenu','add_new_menu');
function add_new_menu(){
$page = add_submenu_page('booking_settings', __( 'New Addon', 'woocommerce-booking' ), __( 'New Addon', 'woocommerce-booking' ), 'manage_woocommerce', 'new_addon', array(&$this, 'new_addon_function' ));
....
}

bkap_product_addon_duplicate: Use this hook to modify/copy booking settings etc. when a duplicate product is being created from a bookable product.

Present in file: woocommerce-booking.php

Usage:

<?php
add_action('bkap_product_addon_duplicate','modify_duplicate',10,2);
?>

Parameters:
$new_id – The post ID of the new product being created.
$old_id – The post ID of the old product from which the duplicate is being created.

Example:

<?php
add_action('bkap_product_addon_duplicate','modify_duplicate',10,2);
function modify_duplicate($new_id,$old_id){
// Add/Insert data as required.
....
}

View Bookings page:

Use the below hooks to add content in the Booking->View Bookings page.

bkap_bookings_page_top: Use this hook to add content at the top of the View Bookings page above the Create Booking, CSV and Print buttons.

Present in file: view-bookings.php

Usage:

<?php 
add_action('bkap_bookings_page_top','add_text');
?>

Parameters:
None

Example:

<?php
add_action('bkap_bookings_page_top','add_text');
function add_text(){
?>
Click on the Create Booking button to create a booking.
<?php
....
}

bkap_bookings_page_bottom: Use this hook to add content at the bottom of the View Bookings page after the bookings list.

Present in file: view-bookings.php

Usage:

<?php 
add_action('bkap_bookings_page_bottom','add_text');
?>

Parameters:
None

Example:

<?php
add_action('bkap_bookings_page_bottom','add_text');
function add_text(){
?>
This is the entire list.
<?php
....
}

Front end product page display:

bkap_before_add_to_cart_button: Use this hook to display a field on the front end product page before the add to cart button.

Present in file: booking-process.php

Usage:

<?php
add_action('bkap_before_add_to_cart_button','display_field',10,1);
?>

Parameters:
$booking_settings – array from the postmeta table that contains the booking settings

Example:

<?php
add_action('bkap_before_add_to_cart_button','display_field,10,1);
function display_field($booking_settings){
....
}

bkap_display_multiple_day_updated_price: Use this hook to calculate and display the product price for multiple day bookings. Please note the hook is not executed in case if the Product type is Grouped Products.

Present in file: booking-process.php

Usage:

<?php
add_action('bkap_display_multiple_day_updated_price','display_price',10,6);
?>

Parameters:
$product_id – The post id of the current product for whom updated price is to be calculated.
$product_type – The product type as simple, variable.
$variation_id_to_fetch – The variation id in case the product is a variable product.
$checkin_date – The checkin date (start date) for multiple day booking in the format d-m-Y.
$checkout_date – The checkout date (end date) for multiple day booking in the format d-m-Y.
$currency_selected – The currency that has been selected in case of multiple currencies.

Example:

<?php
add_action('bkap_display_multiple_day_updated_price','display_price,10,6);
function display_price($product_id,$product_type,$variation_id,$checkin_date,$checkout_date,$currency_selected){
//Calculate the price....
echo $price;
}

The updated price for multiple day booking needs to be echoed so that it can be displayed. Please note that the price for per night should be echoed as it is multiplied by the number of nights in the base plugin itself.


bkap_display_updated_addon_price: Use this hook to calculate and display the price for a product for single day bookings

Present in file: booking-process.php

Usage:

<?php
add_action('bkap_display_updated_addon_price','display_updated_price',10,3);
?>

Parameters:
$product_id – The post ID of the current product being added/edited.
$booking_date – The single day booking date in Y-m-d format.
$variation_id – The variation ID of the variable product whose price needs to be calculated.

Example:

<?php
add_action('bkap_display_updated_addon_price','display_updated_price',10,3);
function display_updated_price($product_id,$booking_date,$variation_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);
//Calculate the price....
echo $price;
}

The updated price needs to be echoed so that it can be displayed on front-end product page.


bkap_display_price_div: Use this hook to display a price div on the front end product page for single day bookings.

Present in file: booking-process.php

Usage:

<?php
add_action('bkap_display_price_div','display_price_div',10,1);
?>

Parameters:
$post>id – The post ID of the current product being added/edited.

Example:

<?php
add_action('bkap_display_price_div','display_price_div',10,1);
function display_price_div($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);
//The price div needs to be displayed here based on the booking settings, if you want to change/update the price for a single day booking...
}

bkap_print_hidden_fields: Use this hook to display hidden fields on the front end product page for bookable products.

Present in file: booking-process.php

Usage:

<?php
add_action('bkap_print_hidden_fields','addon_hidden_fields',10,1);
?>

Parameters:
$product_id – The post ID of the current product being displayed.

Example:

<?php
add_action('bkap_print_hidden_fields','addon_hidden_fields',10,1);
function addon_hidden_fields($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);
//The code required to print the hidden fields based on the booking settings...
}

bkap_js: Use this hook to execute js code from any addon function.

Present in file: booking-process.php

Usage:

<?php
add_action('bkap_js','addon_js_code',10,3);
?>

Parameters:
$booking_date – The start date for a booking
$post_id – The post ID of the current product being displayed.
$addon_data – An addon specific hidden field “#wapbk_addon_data” whose data is being passed. So, this field can be used to pass the data required.

Example:

<?php
add_action('bkap_js','addon_js_code',10,3);
function addon_js_code($booking_date,$post_id,$addon_data){
$settings = get_post_meta($post_id,'woocommerce_booking_settings',true);
// The js code that needs to be executed should be printed
print('jQuery(".partial_message").show();');
}

bkap_validate_cart_items: This hook is used to validate the items on the Cart and Checkout pages. This hook is executed only if the type of time slots selected is set to Multiple.

Present in file: validation.php

Usage:

<?php
add_action('bkap_validate_cart_items','addon_validate',10,1);
?>

Parameters:
$value – It is an array that contains the details about each product in the cart.

Example:

<?php
add_action('bkap_validate_cart_items','addon_validate',10,1);
function addon_validate($value){
// Do the validation as required...
}

Validation and Data Updation:

bkap_update_booking_history: Use this hook to update the booking_history table. i.e. modify time slots, booking availability etc. This hook is executed for each item in the order. This hook is executed only if the type of time slots selected is set to Multiple.

Present in file: checkout.php

Usage:

<?php
add_action('bkap_update_booking_history','update_table',10,2);
?>

Parameters:
$values – It is an array that contains the details about each product in the cart.
$results[0] – It is an array that contains the order item id and the order id from the woocommerce_order_items table for a given item in an order.

Example:

<?php
add_action('bkap_update_booking_history','update_table',10,2);
function update_table($values,$results){
...
}

bkap_order_status_cancelled: Use this hook to cancel an order and update the booking history table for all the timeslots selected. This hook will be run for in a loop for all the items in a given order. This hook is executed only if the type of time slots selected is set to Multiple.

Present in file: cancel-order.php
admin-bookings.php

Usage:

<?php
add_action('bkap_order_status_cancelled:','cancel_order',10,3);
?>

Parameters:
$order_id – The post ID of the current product being added/edited.
$item_value – It is an array that contains the item details for each item.
$booking_id – The id field in the booking history table for the given record which needs to be updated in order to free up the bookings.

Example:

<?php
add_action('bkap_order_status_cancelled:','cancel_order',10,3);
function cancel_order($order_id,$item_value,$booking_id){
//Update the booking_history table to free up the date/time slots of the cancelled order...
}

bkap_send_email: Use this hook to send tickets through mail when an order is placed.

Present in file: checkout.php

Usage:

<?php
add_action('bkap_send_email','send_email',10,1);
?>

Parameters:
$tickets – The ticket array which is obtained from the filter bkap_send_ticket.

Example:

<?php
add_action('bkap_send_email','send_email',10,1);
function send_email($ticket){
//You can use the wp_mail function to send an email to customers using the data in the $ticket array...
}

bkap_update_order: Use this hook to insert Order item meta and it can also be used to modify the Woocommerce tables once the Order has been placed.

Present in file: checkout.php

Usage:

<?php
add_action('bkap_update_order','addon_order_item_meta',10,2);
?>

Parameters:
$values – It is an array that contains the details about each product in the cart.
$results[0] – It is an array that contains the order item id and the order id from the woocommerce_order_items table for a given item in an order.

Example:

<?php
add_action('bkap_update_order','addon_order_item_meta',10,2);
function addon_order_item_meta($values,$order){
$product_id = $values['product_id'];
$quantity = $values['quantity'];
$booking = $values['booking'];
$order_item_id = $order->order_item_id;
$order_id = $order->order_id;
$booking_notes = 'The booking is confirmed';
//Order item meta is added as below
woocommerce_add_order_item_meta($order_item_id,  'Booking Notes', $booking_notes, true );
}

 


Filters:

Admin Settings:

bkap_save_product_settings: Use this filter to save the booking settings on the admin product page.

Present in file: booking-box.php

Usage:

<?php
add_filter('bkap_save_product_settings','save_settings',10,2);
?>

Parameters:
$booking_settings – The booking settings array for the product from the postmeta table.
$product_id – The post ID of the current product being added/edited.

Example:

<?php
add_filter('bkap_save_product_settings','save_settings',10,2);
function save_settings($settings,$product_id){
//Save settings in the array...
return $booking_settings;
}

bkap_save_global_settings: Use this filter to save the global booking settings in the Booking->settings menu.

Present in file: global-menu.php

Usage:

<?php
add_filter('bkap_save_global_settings','save_global_settings',10,1);
?>

Parameters:
$booking_settings – The booking settings array from the options table.

Example:

<?php
add_filter('bkap_save_global_settings','save_global_settings',10,1);
function save_global_settings($values,$results){
//Save the settings in the array...
return $booking_settings;
}

bkap_save_slot_field_settings: Use this filter to save the field values that have been added in the time slot div.

Present in file: booking-box.php

Usage:

<?php
add_filter('bkap_save_slot_field_settings','save_field_settings',10,2);
?>

Parameters:
$date_time_settings – The date time settings array from the post meta booking settings record.
$post_id – The post id that is being added/edited.

Example:

<?php
add_filter('bkap_save_slot_field_settings','save_field_settings',10,2);
function save_field_settings($date_time_settings,$post_id){
//Save the settings in the array...
return $date_time_settings;
}

bkap_add_column_value: Use this filter to to insert the values to be displayed in the new column that has been added in the View/Delete Date and Time Slots tab using ‘bkap_add_column_names’ hook.

Present in file: booking-box.php

Usage:

<?php
add_filter('bkap_add_column_value','addon_column_value',10,2);
?>

Parameters:
$slot_price – A blank array that should be populated with the column values before being returned.
$date_time_settings – The date time settings array from the post meta booking settings record,

Example:

<?php
add_filter('bkap_add_column_value','addon_column_value',10,2);
function addon_column_value($slot_price,$date_time_settings){
//Populate the slot_price array...
return $slot_price;
}

View Bookings page:

Use the below filters to add/edit columns, column data on the View Bookings page as well the data being exported.
bkap_bookings_table_views: Use this filter to add/remove views to the existing 4 views.

Present in file: class-view-bookings-table.php

Usage:

<?php 
add_filter('bkap_bookings_table_views','add_view');
?>

Parameters:
$views – The array which contains all the views. To remove a view, the entire array will have to re-written. In a scenario where a view is being added, a new entry can simply be created in the array and returned.

Example:

<?php
add_filter('bkap_bookings_table_views','add_view');
function add_view($views){
....
$current        = isset( $_GET['status'] ) ? $_GET['status'] : '';
$total = $this->past_count;
$total_count    = ' <span class="count">(' . $total    . ')</span>';
$views['past'] = sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'past', 'paged' => FALSE ) ), $current === 'past' ? ' class="current"' : '', __('Past', 'woocommerce-booking') . $total_count );
return $views;
}

bkap_view_bookings_table_columns: Use this filter to add/remove columns.

Present in file: class-view-bookings-table.php

Usage:

<?php 
add_filter('bkap_view_bookings_table_columns','add_column');
?>

Parameters:
$columns – The array contains all the column names. To remove a column, the entire array will have to re-written. In a scenario where a column needs to be added at the end, a new entry can simply be created in the array and returned. This hook can also be used if you wish to simply change the column names to appear in another language.

Example:

<?php
add_filter('bkap_view_bookings_table_columns','add_column');
function add_column($columns){
....
$columns['email'] = __('Email','woocommerce-booking');
return $columns;
}

bkap_view_bookings_sortable_columns: Use this filter to add/remove columns from the sortable list.

Present in file: class-view-bookings-table.php

Usage:

<?php 
add_filter('bkap_view_bookings_sortable_columns','add_sortable');
?>

Parameters:
$columns – The array which contains the list of column names which are sortable. To remove a column, the entire array will have to re-written. In a scenario where a column needs to be added to the list, a new entry can simply be created in the array and returned.
Example:

<?php
add_filter('bkap_view_bookings_sortable_columns','add_sortable');
function add_sortable($columns){
....
$columns['email'] = array('email',false);
return $columns;
}

bkap_view_bookings_table_data: Use this filter to add/remove customized column data in the Bookings list.

Present in file: class-view-bookings-table.php

Usage:

<?php 
add_filter('bkap bkap_view_bookings_table_data','add_column_data');
?>

Parameters:
$return_booking_display – This array contains the data that is to be displayed in each column on the View Bookings page.
Example:

<?php
add_filter('bkap_view_bookings_table_data','add_column_data');
function add_column_data($columns){
foreach ($booking_data as $key => $value) {
	$order = new WC_Order($value->ID);
	// Email
	$value->email = '';
	if (isset($order->billing_email)) {
		$value->email = $order->billing_email;
	}	
}
return $booking_data;
}

bkap_booking_table_column_default: Use this filter to add/remove customized column data in the Bookings list.

Present in file: class-view-bookings-table.php

Usage:

<?php 
add_filter('bkap_booking_table_column_default','column_defaults',10,3);
?>

Parameters:
$value – Contains the value that should be displayed
$booking – Array which contains the data set by the user to be displayed for each column
$column_name – The column name
Example:

<?php
add_filter('bkap_booking_table_column_default','column_defaults',10,3);
function column_defaults($value, $booking, $column_name){
switch ( $column_name ) {
	case 'email' :
		$value  = ! empty( $booking->email ) ? $booking->email : '';
		break;
}
return $value;
}

bkap_view_bookings_print_columns: Use this filter to add the new column names for printing using the Print button.

Present in file: view-bookings.php

Usage:

<?php 
add_filter('bkap_view_bookings_print_columns','print_columns');
?>

Parameters:
$print_data_columns – This string contains the formatted column names to be printed as headers on the Print page.
Example:

<?php
add_filter('bkap_view_bookings_print_columns',' print_columns ');
function print_columns($print_data_columns){
// Get the column names from the base plugin file
$columns = array();
include_once(ABSPATH . 'wp-content\plugins\woocommerce-booking\class-view-bookings-table.php');
$bookings_table = new WAPBK_View_Bookings_Table();
$columns = $bookings_table->get_columns($columns);
// Create the column names as a row header
$print_data_columns = "<tr>";
foreach ($columns as $key => $value) {
	// Do not print the Actions columns
if ($value != 'Actions') {
       	$print_data_columns .= "<th style='border:1px solid black;padding:5px;'>".__($value,'woocommerce-booking')."</th>"; 
       }
}
$print_data_columns .= "</tr>";
return $print_data_columns; 	
 }

bkap_view_bookings_print_rows: Use this filter to add the new column data for printing using the Print button. This filter needs to be used in conjunction with the bkap_bookings_export_data to ensure that the parameter ($report) being passed contains the data for the new columns.

Present in file: view-bookings.php

Usage:

<?php 
add_filter(' bkap_view_bookings_print_rows ','print_rows',10,2);
?>

Parameters:
$print_data_row_data – This string contains the formatted column data to be printed as rows for each booking on the Print page.
$report – This array contains the data for each column to be printed.
Example:

<?php
add_filter('bkap_view_bookings_print_rows','print_rows',10,2);
function print_rows($print_data_row_data,$report){
//The data for all the columns needs to be added, as we are defining the entire data being printed
$print_data_row_data = '';
foreach ($report as $key => $value) {
$print_data_row_data .= "<tr>
		<td style='border:1px solid black;padding:5px;'>".$value->order_id." </td>
		<td style='border:1px solid black;padding:5px;'>".$value->customer_name."</td>
		<td style='border:1px solid black;padding:5px;'>".$value->product_name."</td>
		<td style='border:1px solid black;padding:5px;'>".$value->checkin_date."</td>
		<td style='border:1px solid black;padding:5px;'>".$value->checkout_date."</td>
		<td style='border:1px solid black;padding:5px;'>".$value->time."</td>
		<td style='border:1px solid black;padding:5px;'>".$value->quantity." </td>
		<td style='border:1px solid black;padding:5px;'>".$value->amount." </td>
		<td style='border:1px solid black;padding:5px;'>".$value->order_date." </td>
		<td style='border:1px solid black;padding:5px;'>".$value->email." </td>
		</tr>";
}
return $print_data_row_data;
 }

bkap_bookings_export_data: Use this filter to add the new column data for export i.e. CSV and Print

Present in file: view-bookings.php

Usage:

<?php 
add_filter('bkap_bookings_export_data','generate_export_data');
?>

Parameters:
$report – This array contains the data for each column to be exported.
Example:

<?php
add_filter('bkap_bookings_export_data',' generate_export_data ');
function $generate_export_data ($report){
foreach ($report as $key => $value) {
	$order = new WC_Order($value->order_id);
	// Email
	$value->email = '';
	if (isset($order->billing_email)) {
		$value->email = $order->billing_email;
	}
}
return $report; 
}

bkap_bookings_csv_data: Use this filter to add the new column data for CSV export.

Present in file: view-bookings.php

Usage:

<?php 
add_filter('bkap_bookings_csv_data','csv_export',10,2);
?>

Parameters:
$csv – This is the string which contains all the csv data
$report – This array contains the data for each column to be exported.
Example:

<?php
add_filter('bkap_bookings_csv_data','csv_export',10,2);
function csv_export($csv,$report) {
	// Get the column names
	$columns = array();
	include_once(ABSPATH . 'wp-content\plugins\woocommerce-booking\class-view-bookings-table.php');
	$bookings_table = new WAPBK_View_Bookings_Table();
	$columns = $bookings_table->get_columns($columns);
	$csv = '';
	// Create column name headers
	foreach ($columns as $key => $value) {
		if ($value != 'Actions') {
			$csv .= $value . ",";
		}
	}
	$csv .= "\n";
	// Add data
	foreach ($report as $key => $value) {
		$csv .= $value->order_id . ',' . $value->customer_name . ',' . $value->product_name . ',"' . $value->checkin_date . '","' . $value->checkout_date . '","' . $value->time . '",' . $value->quantity . ',' . $value->amount . ',' . $value->order_date . ',' . $value->email;
		$csv .= "\n";
	}
	return $csv;
}

Front end product page:

bkap_function_slot: It returns the function name which needs to be called for displaying the timeslots on frontend product page. This hook is executed only if the type of time slots selected is set to Multiple.

Present in file: booking-process.php

Usage:

<?php
add_filter('bkap_function_slot','slot_type',10,1);
?>

Parameters: None

Example:

<?php
add_filter('bkap_function_slot','slot_type',10,1);
function slot_type(){
//Return the slot type.. For example ... 
return 'multiple_type';
}

bkap_slot_type: It returns the timeslot type like “multiple” if user select Type of Slot as multiple on admin product page

Present in file: validation.php
checkout.php
cart.php
cancel-order.php
admin-bookings.php

Usage:

<?php
add_filter('bkap_slot_type','slot_type',10,1);
?>

Parameters:
$post->ID – The post ID of the current product being booked on the front-end product page.

Example:

<?php
add_filter('bkap_slot_type','slot_type',10,1);
function slot_type($product_id){
$settings = get_post_meta($product_id,'woocommerce_booking_settings',true);
//Check the slot type enabled based on the settings and if multiple slots is enabled, it can be returned as below...
return 'multiple';
//If not, then return nothing...
}

 


bkap_get_cart_item_from_session: It returns the cart item from with the adjusted price

Present in file: cart.php

Usage:

<?php
add_filter('bkap_get_cart_item_from_session','get_session_cart',10,2);
?>

Parameters:
$cart_item – It is an array that contains the cart details and which needs to be modified for the price adjustments.
$values – It is an array that contains the details about each product in the cart.

Example:

<?php
add_filter('bkap_get_cart_item_from_session','get_session_cart',10,2);
function get_session_cart($values,$results){
//The price needs to be modified as below where $extra-cost contains the adjust (+10, -15 and so on)
$cart_item['data']->adjust_price( $extra_cost );
return $cart_item;
}

bkap_get_item_data: This filter can be used to add new details to the bookable items on the Cart page, Checkout page and the Order Received page. The details for all the products should be added by running a for loop for the cart items.

Present in file: cart.php

Usage:

<?php
add_filter('bkap_get_item_data','get_item_data',10,2);
?>

Parameters:
$other_data – It is the array that contains the details to be displayed on the cart page,Checkout Page and Order Received page.
$cart_item – It is the array that contains the cart details.

Example:

<?php
add_filter('bkap_get_item_data','get_item_data',10,2);
function get_item_data($other_data,$cart_item){
...
$price = '10';
$other_data[] = array(
		'name'    => 'Additional Fees',
		'display' => $price
		);
return $other_data;
}

bkap_block_dates: This filter returns the blocked dates.

Present in file: booking-process.php

Usage:

<?php
add_filter('bkap_block_dates','get_blocked_dates',10,2);
?>

Parameters:
$post->ID – The post ID of the current product.
$blocked_dates – It is an empty array which is sent to be populated with the dates

Example:

>?php
add_filter('bkap_block_dates','get_blocked_dates',10,2);
function get_blocked_dates($product_id,$dates){
$block_dates[] = array();
...
$block_dates['calendar'] = ...; // 
$block_dates['date_label'] = ..; //
$block_dates['dates'] = ...; //Dates that are to be blocked
$block_dates['add_days_to_charge_booking'] = ..; //Blocked days that should be chargeable
$block_dates['same_day_booking'] = ...; //
return $block_dates;
}

bkap_addon_add_cart_item_data: It is used to edit the price of the bookable item when the product is being added to the cart.

Present in file; cart.php

Usage:

<?php
add_filter('bkap_addon_add_cart_item_data','addon_add_cart_item_data',10,4);
?>

Parameters:
$cart_arr – It is the array that contains the booking details.
$product_id – It is the post ID of the item being added to the cart.
$variation_id – It is the variation ID in case of a variable product.
$cart_item_meta – It is an array that contains the cart details where the booking details need to be added. This is done by the base plugin.

Example:

<?php
add_filter('bkap_addon_add_cart_item_data','addon_add_cart_item_data',10,4);
function addon_add_cart_item_data($cart_arr, $product_id, $variation_id,$cart_item_meta){
$cart_arr['price'] = 500;
return $cart_item;
}

bkap_validate_add_to_cart: This hook is used to validate the available quantity when the product is added to the cart. This hook is executed only if the type of time slots selected is set to Multiple.

Present in file: validation.php

Usage:

<?php
add_action('bkap_validate_add_to_cart','addon_add_to_cart_validate',10,2);
?>

Parameters:
$_POST – The $_POST array contains the details of the product being added to the cart.
$post>ID – The post ID of the product that is being added to the cart.

Example:

<?php
add_action('bkap_validate_add_to_cart','addon_add_to_cart_validate',10,2);
function addon_add_to_cart_validate($_POST,$product_id){
// Do the validation as required...
}

bkap_block_weekdays: This filter is used to disable certain weekdays in the check-in and check-out calendar when using Multiple Day booking method. Since there is no direct way to do this from the plugin directly, this hook fills that gap.

Present in file: booking-process.php

Usage:

<?php
add_filter( 'bkap_block_weekdays','block_weekdays', 10, 1 );
?>

Parameters:
$block_weekdays – It is a blank array passed to the function.

Example:

<?php
add_filter( 'bkap_block_weekdays','block_weekdays',10, 1 );
function block_weekdays( $block_weekdays ){
// Disable the weekdays
$block_weekdays['checkin'][]  = 'saturday';
$block_weekdays['checkin'][]  = 'sunday';
    
$block_weekdays['checkout'][] = 'saturday';
$block_weekdays['checkout'][] = 'sunday';

return $block_weekdays;
}

Widget Search:

bkap_add_search_widget_id: It returns the div ID under which the Booking search widget is located

Present in file: widget-product-search.php

Usage:

<?php
add_filter( 'bkap_add_search_widget_id', 'widget_tag_id', 10, 1 );
?>

Parameters:
$add_anchor_tag – It is a blank field passed to the function

Example:

<?php
add_filter( 'bkap_add_search_widget_id', 'widget_tag_id', 10, 1 );
function widget_tag_id( $search_widget_id_name ) {
// Set the div ID
$search_widget_id_name = 'example-div';  
return $search_widget_id_name;
}

The ID returned will be used in the url created when a date/date range is searched in the Widget. When the page is loaded after the search, it will directly take the user to the widget, thus ensuring the user does not have to scroll up/down the page to see the widget.


Validation and sending data:

bkap_send_ticket: It returns the ticket created based on setting

Present in file: checkout.php

Usage:

<?php
add_filter('bkap_send_ticket','send_ticket',10,2);
?>

Parameters:
$values – It is an array that contains the details about each product in the cart.
$order_obj – It is an array that contains the order details. For example billing first name, last name etc.

Example:

<?php
add_filter('bkap_send_ticket','send_ticket',10,2);
function send_ticket($values,$order){
//Create the ticket variables... and return them as..
$ticket[] = array('to'=>$to, 'subject' => $subject, 'message' => $message, 'headers' => $headers);
return $ticket;
}

The ticket returned from this filter will be used to be sent to the customer via email.

Subscribe Now

Stay in touch!

Stay in touch!

Receive notifications about important plugin updates, discounts, and sneak previews of upcoming plugin releases from our team.

Thanks for subscribing! Please check your email for further instructions.