1. Home
  2. Booking & Appointment Plugin for WooCommerce – NEW
  3. Hooks and Filters Documentation

Hooks and Filters Documentation

The following is a list of all hooks and filters present in the plugin. Hooks and Filters allow developers to modify or extend the functionality of the Booking & Appointment for WooCommerce Plugin plugin without directly editing core files.

How can I disable the ‘Inline Calendar’ option from all bookable products?

Hook:
init:

Usage:

add_action( "init", "admin_init_script_disabling_inline" );

Parameters: None

Example:

/**
 * Add this code snippet in functions.php file of your currently active theme.
 * Once that is done then visit the site.
 * Visiting the site will execute this function which will disable the Inline Calendar option.
 * Comment the hook or remove code once the above steps are followed.
 * Else the code will execute each time the site is visited.
 */
function admin_init_script_disabling_inline(){

  $bkap_common        = new bkap_common();
  $bookable_products  = bkap_common::get_woocommerce_product_list( false, "on" );
  foreach ( $bookable_products as $key => $value ) {
    $product_id = $value[1];
    $booking_settings = get_post_meta( $product_id, 'woocommerce_booking_settings', true );
    $booking_settings['enable_inline_calendar'] = '';
    update_post_meta( $product_id, 'woocommerce_booking_settings', $booking_settings );
    update_post_meta( $product_id, '_bkap_enable_inline', '' );
  }
}
add_action( "init", "admin_init_script_disabling_inline" );

How can I display the Booking form above the Product’s short description on a mobile device?

Hook:
woocommerce_before_single_product:

Usage:

add_action( 'woocommerce_before_single_product', 'woocommerce_single_product_summary_mobile', 29 );

Parameters: None

Example:

function woocommerce_single_product_summary_mobile(){
  global $post;
  $product_id       = $post->ID;
  $booking_settings = get_post_meta( $product_id , 'woocommerce_booking_settings' , true );
   
  if ( isset( $booking_settings ) && isset( $booking_settings[ 'booking_enable_date' ] ) && 'on' == $booking_settings[ 'booking_enable_date' ] ) {

    $product      = wc_get_product( $product_id );
    $product_type = $product->get_type();
    
    if ( "bundle" !== $product_type ) {
      if ( wp_is_mobile() ){
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );      
        add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 11 );
      }
    }
  }
}
add_action( 'woocommerce_before_single_product', 'woocommerce_single_product_summary_mobile', 29 );

How to display additional information in the event tip on the Calendar View for all bookings?

Hook:
bkap_additional_data_value_in_calendar_tip , bkap_display_additional_info_in_calendar_tip:

Usage:

add_filter( "bkap_additional_data_value_in_calendar_tip", "bkap_additional_data_value_in_calendar_tip", 10, 2 );

Parameters: 2

add_filter( "bkap_display_additional_info_in_calendar_tip", "bkap_display_additional_info_in_calendar_tip", 10, 2 );

Parameters: 2

Example:

/**
 * This funtion will add extra information in the value array.
 *
 * @param array $value Prepared array of values being displayed in the tip.
 * @param object $booking Booking Object 
 */
function bkap_additional_data_value_in_calendar_tip( $value, $booking ){

	$order = $booking->get_order();
	$value['customer_email'] = $order->get_billing_email();
    $value['billing_phone']  = $order->get_billing_phone();
    $value['order_comments'] = $order->get_customer_note();

	return $value;
}

/**
 * This funtion will add extra information in the value array.
 *
 * @param string $content Information being displayed in the tip
 * @param array $value Array of values
 */
function bkap_display_additional_info_in_calendar_tip( $content, $value ){

	if ( isset( $value[ 0 ][ 'customer_email' ] ) && $value[ 0 ][ 'customer_email' ] != '' ){
		$customer_email  = $value[ 0 ][ 'customer_email' ];
		$content        .= " Email:  ".$customer_email."

“; } if ( isset( $value[ 0 ][ ‘billing_phone’ ] ) && $value[ 0 ][ ‘billing_phone’ ] != ” ){ $billing_phone = $value[ 0 ][ ‘billing_phone’ ]; $content .= ”

 Phone Number:  ".$billing_phone."

“; } if ( isset( $value[ 0 ][ ‘order_comments’ ] ) && $value[ 0 ][ ‘order_comments’ ] != ” ){ $order_comments = $value[ 0 ][ ‘order_comments’ ]; $content .= ”

 Order note:  ".$order_comments."

“; } return $content; } add_filter( “bkap_additional_data_value_in_calendar_tip”, “bkap_additional_data_value_in_calendar_tip”, 10, 2 ); add_filter( “bkap_display_additional_info_in_calendar_tip”, “bkap_display_additional_info_in_calendar_tip”, 10, 2 );


How to charge for only one night, regardless of the number of nights selected by the customer?

Hook:
bkap_number_ofselected_days_on_weekend:

Usage:

add_filter( "bkap_number_ofselected_days_on_weekend", "bkap_number_ofselected_days_on_weekend_call", 10, 1 );

Parameters: 1

Example:

/**
 * This funtion will charge only for one night.
 *
 * @param int $number Number of nights
 */
function bkap_number_ofselected_days_on_weekend_call( $number ) {
  return 1;
}
add_filter( "bkap_number_ofselected_days_on_weekend", "bkap_number_ofselected_days_on_weekend_call", 10, 1 );

When you don’t want to consider the advance booking period for the Admin/Store Owner?

Hook:
bkap_advance_booking_period:

Usage:

add_filter( 'bkap_advance_booking_period', 'bkap_advance_booking_period_callback', 10, 1 );

Parameters: 1

Example:

/**
 * This funtion will not consider the advance booking period on admin end.
 *
 * @param int $abp Advance booking period value
 */
function bkap_advance_booking_period_callback( $abp ) {
  if ( is_admin() ) {
    $abp = 0;
  }
  return $abp;
}
add_filter( 'bkap_advance_booking_period', 'bkap_advance_booking_period_callback', 10, 1 );

When would you want to modify the product price according to the Fixed Block price in the WC API?

Hook:
woocommerce_api_product_response:

Usage:

add_filter( 'woocommerce_api_product_response', 'wc_api_add_custom_data_to_product', 10, 2 );

Parameters: 2

Example:

function wc_api_add_custom_data_to_product( $product_data, $product ) {

   $price = bkap_get_fixed_block_price( $product->get_id(), $product->get_price() );

  // retrieve a custom field and add it to API response
  $product_data['price'] = $price;

  return $product_data;
}
add_filter( 'woocommerce_api_product_response', 'wc_api_add_custom_data_to_product', 10, 2 );

How to add a Custom Booking status?

Hook:
bkap_get_bkap_booking_statuses, bkap_registering_custom_booking_status, the_posts:

Usage:

add_filter( "bkap_get_bkap_booking_statuses", "bkap_get_bkap_booking_statuses_callback", 10, 1 );

Parameters: 1

add_action("bkap_registering_custom_booking_status", "bkap_registering_custom_booking_status" );

Parameters: None

add_filter( 'the_posts', 'bar_filter_posts', 1 );

Parameters: 1

Example:

add_filter( "bkap_get_bkap_booking_statuses", "bkap_get_bkap_booking_statuses_callback", 10, 1 );
function bkap_get_bkap_booking_statuses_callback( $status ){
  $status['delivered'] = "Delivered";
  return $status;
}

add_action("bkap_registering_custom_booking_status", "bkap_registering_custom_booking_status" );
function bkap_registering_custom_booking_status(){
  register_post_status( 'delivered', array(
                'label'                     => '' . _x( 'Delivered', 'woocommerce-booking', 'woocommerce-booking' ) . '',
                'public'                    => true,
                'exclude_from_search'       => false,
                'show_in_admin_all_list'    => true,
                'show_in_admin_status_list' => true,
                'label_count'               => _n_noop( 'Delivered (%s)', 'Delivered (%s)', 'woocommerce-booking' ),
                ) );
}

add_filter( 'the_posts', 'bar_filter_posts', 1 );
function bar_filter_posts( $posts ) {

    if ( is_admin() && !isset( $_GET['post_status'] ) ):        
        $new_posts = array();        
        foreach( $posts as $post ) {
            
            $booking = "";            
            if ( $post->post_type == 'bkap_booking' ) {
                $product_id = get_post_meta( $post->ID, '_bkap_product_id', true );
                $booking = new BKAP_Booking( $post->ID );
                if ( $booking->status != 'delivered' ){
                  $new_posts[] = $post;  
                }
                
            } else {
                 return $posts;
            }
        }
        return $new_posts;
    endif;

    return $posts;
}

How can you modify the “Number of Days” text and adjust the Numbers accordingly?

Hook:
bkap_selected_days_label, bkap_selected_days_value, bkap_selected_days_full_text:

Usage:

add_filter( 'bkap_selected_days_label', 'bkap_selected_days_label_callback', 10, 3 );

Parameters: 3

add_filter( 'bkap_selected_days_value', 'bkap_selected_days_value_callback', 10, 5 );

Parameters: 5

add_filter( 'bkap_selected_days_full_text', 'bkap_selected_days_full_text_callback', 10, 7 );

Parameters: 7

Example:

/**
 * Change Number of Days text.
 *
 * @param string $text Number of Days string.
 * @param int    $product_id Product ID.
 * @param array  $booking_settings Booking Settings.
 */
function bkap_selected_days_label_callback( $text, $product_id, $booking_settings ) {

	$text = __( 'Selected Days:', 'woocommerce-booking' );
	return $text;
}
add_filter( 'bkap_selected_days_label', 'bkap_selected_days_label_callback', 10, 3 );


/**
 * Modify days count based on the holidays in the date range.
 *
 * @param int    $number Number.
 * @param string $checkin_date Checkin Date.
 * @param string $checkout_date Checkout Date.
 * @param int    $product_id Product ID.
 * @param array  $booking_settings Booking Settings.
 */
function bkap_selected_days_value_callback( $number, $checkin_date, $checkout_date, $product_id, $booking_settings ) {

	$holidays = array_keys( $booking_settings['booking_product_holiday'] );
	$dates    = bkap_common::bkap_get_betweendays( $checkin_date, $checkout_date, 'Y-m-d' );

	foreach ( $holidays as $holiday ) {
		$day = date( 'Y-m-d', strtotime( $holiday ) );
		if ( in_array( $day, $dates ) ) {
			$number = $number - 1;
		}
	}

	return $number;
}
add_filter( 'bkap_selected_days_value', 'bkap_selected_days_value_callback', 10, 5 );



/**
 * Modify complete message being shown for Number of Days.
 *
 * @param string $text Number of days selected infomration msg along with numbers.
 * @param string $selected_days_text Number of days selected string.
 * @param int    $number Number.
 * @param string $checkin_date Checkin Date.
 * @param string $checkout_date Checkout Date.
 * @param int    $product_id Product ID.
 * @param array  $booking_settings Booking Settings.
 */
function bkap_selected_days_full_text_callback( $text, $selected_days_text, $number, $checkin_date, $checkout_date, $product_id, $booking_settings ) {

	$text      = 'You have selectetd ' . $checkin_date . ' and ' . $checkout_date . '
';
	$days      = 'Number of days are ' . $number . '
';
	$final_msg = $text . $days;

	return $final_msg;
}
add_filter( 'bkap_selected_days_full_text', 'bkap_selected_days_full_text_callback', 10, 7 );

How can you remove the License menu from the Booking menu?

Hook:
admin_menu:

Usage:

add_action( 'admin_menu', 'remove_submenu', 999 );

Parameters: None

Example:

/**
 * Removing the License menu from Booking menu.
 */
function remove_submenu() {
	remove_submenu_page( 'edit.php?post_type=bkap_booking', 'booking_license_page' );
}

add_action( 'admin_menu', 'remove_submenu', 999 );

How can you add 24 hours to Advance Booking Period Modification based on holiday and disabled weekday?

Hook:
bkap_advance_booking_period:

Usage:

add_filter( 'bkap_advance_booking_period', 'bkap_advance_booking_period', 10, 2 );

Parameters: 2

Example:

/**
 * Adding days( 24 hours ) to Advance Booking Period if days falling in ABP are holidays or disabled weekdays
 * 
 * @param int $abp Advance Booking Period Value.
 * @param array $bkap_settings Booking Settings
 * 
 * @return int
 */
function bkap_advance_booking_period( $abp, $bkap_setting ){

	if ( $abp ) {
		$current_time     = current_time( 'timestamp' );
		$current_date     = date( 'j-n-Y', $current_time );
		$abp_current_time = $current_time + ( $abp * 3600 );
		$date             = date( 'j-n-Y', $abp_current_time );
		$days             = array();

		if ( $current_date != $date ) {             
            while( $current_time < strtotime($date) ) { $currentDate = date( 'j-n-Y', strtotime( "+1 day", $current_time ) ); $current_time = $current_time + 86400; $days[] = $currentDate; } } if ( count( $days ) > 0 ) {
			$holiday           = array();
			$hour              = 0;
			$booking_recurring = $bkap_setting['booking_recurring'];

			if ( isset( $bkap_setting['booking_product_holiday'] ) && !empty( $bkap_setting['booking_product_holiday'] ) ) {
				$holiday = array_keys( $bkap_setting['booking_product_holiday'] ); 
			}

			foreach( $days as $day ) {
				if ( in_array( $day, $holiday ) ) { // Add 24 for it its holiday
					$hour += 24;
					continue;
				}

				// add 24 hours if its disabled weekdays
				$weekday = date( 'w', strtotime( $day ) );
				$weekday = "booking_weekday_$weekday";
				if ( isset( $booking_recurring[$weekday] ) && '' == $booking_recurring[$weekday] ) {
					$hour += 24;
					continue;
				}
			}

			$abp += $hour;
		}
	}
	return $abp;

}
add_filter( 'bkap_advance_booking_period', 'bkap_advance_booking_period', 10, 2 );

How can you show the availability message only for particular product?

Hook:
bkap_global_settings, bkap_show_availability_in_duration_blocks:

Usage:

add_filter( 'bkap_global_settings', 'bkap_global_settings_callback', 10 );

Parameters: 1

add_filter( 'bkap_show_availability_in_duration_blocks', 'bkap_show_availability_in_duration_blocks_callback', 10, 1 );

Parameters: 1

Example:

/** 
 * Enable Availability message display only for particular products.
 * 
 * @param obj $global_settings Global Booking Settings
 */
function bkap_global_settings_callback( $global_settings ) {
	if ( get_post_type() == "product" ) {

		$ids = array( 2352 ); // list of product ids
		$id  = get_the_ID();
		if ( in_array( $id, $ids ) ) {
			$global_settings->booking_availability_display = 'on';
		}
	}

	return $global_settings;
}
add_filter( 'bkap_global_settings', 'bkap_global_settings_callback', 10 );

/* For duration based time */
function bkap_show_availability_in_duration_blocks_callback( $display ) {	
	
	if ( isset( $_POST['post_id'] ) && '' != $_POST['post_id'] ) {
		$ids = array( 4057,4058,4113, 4114 ); // list of product ids
        $id = $_POST['post_id'];
        if ( in_array( $id, $ids ) ) {
            return true;
		}
	}

    return $display;
}
add_filter( 'bkap_show_availability_in_duration_blocks', 'bkap_show_availability_in_duration_blocks_callback', 10, 1 );

How can you add Additional Information in Google Event Summary and Description?

Hook:
bkap_google_event_summary, bkap_google_event_description:

Usage:

add_filter( 'bkap_google_event_summary', 'bkap_google_event_summary_callback', 10, 2 );

Parameters: 2

add_filter( 'bkap_google_event_description', 'bkap_google_event_description_callback', 10, 2 );

Parameters: 2

Example:

/**
 * Additonal Information in Google Event Summary
 * 
 * @param string $summary Inforation of the Google Event Summary.
 * @param obj    $data Prepared App data for Gcal Calculation.
 */
function bkap_google_event_summary_callback( $summary, $data ){

	$summary .= ' This is additional infomration event summary';
	return $summary;
}
add_filter( 'bkap_google_event_summary', 'bkap_google_event_summary_callback', 10, 2 );

/**
 * Additonal Information in Google Event Description
 * 
 * @param string $desc Inforation of the Google Event Description.
 * @param obj    $data Prepared App data for Gcal Calculation.
 */
function bkap_google_event_description_callback( $desc, $data ){

	$desc .= ' This is additional infomration in event description';
	return $desc;
}
add_filter( 'bkap_google_event_description', 'bkap_google_event_description_callback', 10, 2 );

How can you change the “Select Resource” text on the Shop page for specific products?

Hook:
bkap_change_select_resource_text:

Usage:

add_filter( 'bkap_change_select_resource_text', 'bkap_change_select_resource_text_callback', 10, 2 );

Parameters: 2

Example:

/**
 * Changing the Select Resource Text on the Shop page for list of products
 * 
 * @param string $text Select Resource Text.
 * @param int $product_id Product ID
 * 
 * @return string
 */
function bkap_change_select_resource_text_callback( $text, $product_id ) {

    $ids = array( 123, 456, 789 ); // Product ids of resource product for which you want to change the text. 
    if ( in_array( $product_id, $ids ) ) {
        $text = __( 'New Resource Text', 'woocommerce-booking' );
    }

    return $text;
}
add_filter( 'bkap_change_select_resource_text', 'bkap_change_select_resource_text_callback', 10, 2 );

How can you calculate the duration price based on a single duration, ensuring that no matter how many durations the customer selects, the price is calculated for only one duration?

Hook:
bkap_fixed_duration_price:

Usage:

add_filter( 'bkap_fixed_duration_price', 'bkap_fixed_duration_price_callback', 10, 1 );

Parameters: 1

Example:

/** 
 * Always calculate the price for according to 1 duration
 * 
 * @param int $duration Selected Duration by customer
 * 
 * @return array
 */
function bkap_fixed_duration_price_callback( $duration ) {
	
	$duration = 1; // Price will be always calculated according to 1 duration even if the customer has chosen any duration.

	return $duration;
}
add_filter( 'bkap_fixed_duration_price', 'bkap_fixed_duration_price_callback', 10, 1 );

How can you manipulate the Duration price based on the selected duration?

Hook:
bkap_final_duration_price:

Usage:

add_filter( 'bkap_final_duration_price', 'bkap_final_duration_price_callback', 10, 4 );

Parameters: 4

Example:

/** 
 * Manipulating the Duration price based on the selected duration.
 * 
 * @param string $final_price Final Price Calculated based on the Settings
 * @param string $product_id Product ID
 * @param string $booking_settings Booking Settings
 * @param string $post POST data 
 */
function bkap_final_duration_price_callback( $final_price, $product_id, $booking_settings, $post ) {
        // here 2587 is Product ID, array is the combination of duration => price
	$prices = array(
				'2587' => array( '1' => '1000', '2' => '1500', '3' => '2000', '4' => '2750' ),  // 1 = 30 mins, 2 = 1 hour, 3 = 1.5 hour, 4 = 2 hours
				'2589' => array( '1' => '20', '2' => '30', '3' => '35', '4' => '45' ),
			);
	
	if ( in_array( $product_id, array_keys( $prices ) ) ) {
		$price_basedon_durations = $prices[ $product_id ];
		$selected_duration       = $post['bkap_duration'];
		$final_price             = isset( $price_basedon_durations[ $selected_duration ] ) ? $price_basedon_durations[ $selected_duration ] : $final_price;
	}

	return $final_price;
}
add_filter( 'bkap_final_duration_price', 'bkap_final_duration_price_callback', 10, 4 );

How can you calculate the Advance Booking Period based on the ‘To’ Time?

Hook:
bkap_change_date_comparison_for_abp:

Usage:

add_filter( 'bkap_change_date_comparison_for_abp', 'bkap_change_date_comparison_for_abp_callback', 10, 6 );

Parameters: 6

Example:

/** 
 * Change Date Comparison for Advance Booking Period.
 * Using this filter you can prepare date based on to time of the booking.
 * E.g ABP is set to 1 and timeslot is 09:00 am to 06:00 pm and the current time is 12:00 pm
 * This timeslot will be shown in the dropdown till the current time is 05:00 pm.
 * 
 * @param string $time Date and Time String
 * @param string $date Date
 * @param string $from From Time
 * @param string $to To Time
 * @param string $product_id Product ID
 * @param string $booking_settings Booking Settings
 */
function bkap_change_date_comparison_for_abp_callback( $time, $date, $from, $to, $product_id, $booking_settings ) {
	return $date . ' ' . $to;
}
add_filter( 'bkap_change_date_comparison_for_abp', 'bkap_change_date_comparison_for_abp_callback', 10, 6 );

How can you hide the Resource Price from the Resource Dropdown?

Hook:
bkap_resource_price_in_dropdown:

Usage:

add_filter( 'bkap_resource_price_in_dropdown', 'bkap_resource_price_in_dropdown_callback', 10, 3 );

Parameters: 3

Example:

/** 
 * Do not show Price in the Resource Dropdown.
 * 
 * @param string $price_str Price String.
 * @param array  $resource_data Resource Data.
 * @param int    $product_id Product ID.
 * 
 * @return string
 */
function bkap_resource_price_in_dropdown_callback( $price_str, $resource_data, $product_id ){
	return '';
}
add_filter( 'bkap_resource_price_in_dropdown', 'bkap_resource_price_in_dropdown_callback', 10, 3 );

How can you Add/Remove a Product from being considered for Global Time Slots Booking?

Hook:
bkap_init_parameter_localize_script_additional_data, bkap_allow_backdated_bookings:

Usage:

add_filter( 'bkap_init_parameter_localize_script_additional_data', 'bkap_init_parameter_localize_script_additional_data_callback', 10, 1 );

Parameter: 1

add_filter( 'bkap_allow_backdated_bookings', 'bkap_allow_backdated_bookings_callback', 10, 1 );

Parameters: 1

Example:

/** 
 * Modifying the Additional Data for setting min and default date to past dates
 * 
 * @param array $data Additional Data
 * 
 * @return array
 */
function bkap_init_parameter_localize_script_additional_data_callback( $data ) {

	if ( is_admin() ) {
		$data['min_date']     = '1-1-2020';
		$data['default_date'] = '1-1-2020';
		$data['number_of_dates'] = -1;
	}
	return $data;
}
add_filter( 'bkap_init_parameter_localize_script_additional_data', 'bkap_init_parameter_localize_script_additional_data_callback', 10, 1 );

/** 
 * Allowing Backdated Event
 * 
 * @param int $backdated_event Backdated Event
 * 
 * @return array
 */
function bkap_allow_backdated_bookings_callback( $backdated_event ) {
	// if the dates are passed then it sets to 1 and here we are passing 0 to allow backdated event
	return 0;
}
add_filter( 'bkap_allow_backdated_bookings', 'bkap_allow_backdated_bookings_callback', 10, 1 );

How can you display the Fixed Block Price on the Shop Page?

Hook:
woocommerce_after_shop_loop_item:

Usage:

add_action( 'woocommerce_after_shop_loop_item', 'bkap_shop_display_fixed_price', 9 );

Parameters: None

Example:

/**
 * Show Fixed Block Price on Shop Page.
 */
function bkap_shop_display_fixed_price() {
	
	global $product;
	
	if ( function_exists( 'is_booking_active' ) ) {
		$product_id  = $product->get_id();
		$is_bookable = bkap_common::bkap_get_bookable_status( $product_id );
		if ( $is_bookable ) {

			$booking_settings = bkap_setting( $product_id );
		
			if ( isset( $booking_settings['booking_fixed_block_enable'] )
				&& $booking_settings['booking_fixed_block_enable'] == 'booking_fixed_block_enable'
				&& $booking_settings['bkap_fixed_blocks_data']
				&& ! empty( $booking_settings['bkap_fixed_blocks_data'] )
			) {

				$price = bkap_get_fixed_block_price( $product_id, $product->get_price() );
				echo '
Rental: ‘ . $price . ‘

‘; } } } } add_action( ‘woocommerce_after_shop_loop_item’, ‘bkap_shop_display_fixed_price’, 9 );


How can you ensure that the Variation price is not added to the Fixed Block Price?

Hook:
bkap_allow_variation_price:

Usage:

add_filter( 'bkap_allow_variation_price', '__return_false' );

Parameters: None

Example:

add_filter( 'bkap_allow_variation_price', '__return_false' );

How can you change the Price Heading based on the Booking Price set in the Booking Meta Box?

Hook:
woocommerce_get_price_html:

Usage:

add_filter( 'woocommerce_get_price_html', 'bkap_woocommerce_get_price_html', 10, 2 );

Parameters: 2

Example:

/** 
 * Change Price Heading Based on the Booking Price set in Booking Meta Box
 *
 * @param string $price Price String
 * @param obj    $product Product Object
 * 
 * Note: Currently available only for Fixed Time Booking Type.
 * Created based on client requirements. To display the price for all the types will take time so later we can work.
 * 
 * @return string
 */
function bkap_woocommerce_get_price_html( $price, $product ) {	

	if ( ! function_exists( 'is_booking_active' ) ) {
		return $price;
	}
	
	$product_id = $product->get_id();
	$bookable   = bkap_common::bkap_get_bookable_status( $product_id );

	if ( $bookable ) {
		$data             = get_post( $product_id );
		$booking_type     = $data->_bkap_booking_type;
		$booking_settings = $data->woocommerce_booking_settings;
		$current_time     = current_time( 'timestamp' );
		$jny_date         = date( 'j-n-Y', $current_time );
		$special_price    = bkap_special_booking_price::get_price( $product_id, $jny_date ); // later pass blank date to get price array 

		switch ( $booking_type ) {
			case 'only_day':				
				break;
			case 'multiple_days':				
				break;
			case 'date_time':
				$bkap_price            = array();
				$booking_time_settings = $data->_bkap_time_settings;
				$price_blank           = false;

				foreach( $booking_time_settings as $daydate => $time_data ) {
					foreach ( $time_data as $key => $value ) {
						if ( '' != $value['slot_price'] ) {
							$bkap_price[] = $value['slot_price'];
						} else {
							$price_blank = true;
						}
					}
				}

				if ( ! empty( $bkap_price) ) {
					$bkap_price     = array_unique( $bkap_price );
					$bkap_min_price = min( $bkap_price );
					$bkap_max_price = max( $bkap_price );

					if ( $bkap_min_price == $bkap_max_price ) {

						if ( count( $bkap_price ) == 1 ) { // When only one price then see if special price is set
							if ( '' != $special_price && $price_blank ) {
								if ( $special_price < $bkap_min_price ) {
									$price1 = $special_price;
									$price2 = $bkap_min_price;
								} else {
									$price1 = $bkap_min_price;
									$price2 = $special_price;
								}
								$price1 = wc_price( $price1 );
								$price2 = wc_price( $price2 );

								$price = $price1 . ' - ' . $price2;
							} else {
								$price = wc_price( $bkap_min_price );
							}
						} else {
							$price = wc_price( $bkap_min_price );
						}
						
					} else {

						if ( '' != $special_price && $price_blank && $special_price < $bkap_min_price ) {
							$bkap_min_price = $special_price;
						}

						$bkap_min_price = wc_price( $bkap_min_price );
						$bkap_max_price = wc_price( $bkap_max_price );
						$price = $bkap_min_price . ' - ' . $bkap_max_price;
					}
				}
				break;
			case 'duration_time':				
				break;
		}
	}

	return $price;
}
add_filter( 'woocommerce_get_price_html', 'bkap_woocommerce_get_price_html', 10, 2 );

How can you sort the resource options in Ascending order?

Hook:
bkap_get_resource_costs:

Usage:

add_filter( 'bkap_get_resource_costs', 'bkap_modify_resource_data', 10, 2 );

Parameters: 2

Example:

/**
 * Function to sort Resources in Ascending Order. In the below function the resource data is manipulated to sort based on titles.
 * bkap_get_resource_costs - Filter gives access to all the Filter data.
 *
 * @param array $resource_data Array of Resource id and cost.
 * @param int   $product_id Product ID.
 *
 * @return array
 */
function bkap_modify_resource_data( $resource_data, $product_id ){

	foreach ( $resource_data as $key => $value ) {
		$title                   = get_the_title( $key );
		$resource_titles[ $key ] = $title;
	}

	asort( $resource_titles );

	foreach ( $resource_titles as $r_key => $r_title ) {
		$resource_titles[ $r_key ] = $resource_data[ $r_key ];
	}

	$resource_data = $resource_titles;

	return $resource_data;
}
add_filter( 'bkap_get_resource_costs', 'bkap_modify_resource_data', 10, 2 );

How can you change the default status of a booking to “confirmed” when the order is placed?

Hook:
bkap_booking_status_on_create_order:

Usage:

add_filter( 'bkap_booking_status_on_create_order', 'bkap_booking_status_on_create_order', 10, 1 );

Parameters: 1

Example:

/**
 * Change default booking status to confirmed when order is placed.
 *
 * @param string $status Status of Booking.
 */
function bkap_booking_status_on_create_order( $status ) {
	return 'confirmed';
}
add_filter( 'bkap_booking_status_on_create_order', 'bkap_booking_status_on_create_order', 10, 1 );

How can you prevent the resource price from being calculated based on quantity?

Hook:
bkap_modify_booking_price:

Usage:

add_filter( 'bkap_modify_booking_price', 'bkap_modify_booking_price', 10, 4 );

Parameters: 4

Example:

/**
 * Do not calculate the resource price according to quantity.
 *
 * @param float $time_slot_price Price.
 * @param int $product_id Product ID.
 * @param int $variation_id Variation ID.
 * @param string $product_type Product Type.
 */
function bkap_modify_booking_price( $time_slot_price, $product_id, $variation_id, $product_type ){

	if ( isset( $_POST['resource_id'] ) && '' != $_POST['resource_id'] ) {
		$resource_id    = $_POST['resource_id'];
		$resource       = new BKAP_Product_Resource( $resource_id, $product_id );
		$resource_price = $resource->get_base_cost();

		if ( 0 != $resource_price ) {
			$time_slot_price = $time_slot_price - $resource_price;
			$resource_price  = $resource_price / $_POST['quantity'];
			$time_slot_price = $time_slot_price + $resource_price;
		}
	}
	return $time_slot_price;
}
add_filter( 'bkap_modify_booking_price', 'bkap_modify_booking_price', 10, 4 );

How can you add the Extra Options information to a Google Event?

Hook:
bkap_google_event_description:

Usage:

add_filter( 'bkap_google_event_description', 'bkap_google_event_description_callback', 10, 2 );

Parameters: 2

Example:

/**
 * Adding the meta data to the Google Event Description
 *
 * @param string $description Event Description.
 * @param obj    $app Objection of all information for the calculation.
 */
function bkap_google_event_description_callback( $description, $app ) {

	$item_id             = $app->item_id;
	$item                = new WC_Order_Item_Product( $item_id );
	$item_data           = $item->get_data();
	$formatted_meta_data = $item->get_formatted_meta_data( '_', true );

	$name           = get_option( 'book_item-meta-date' );
	$name           = ( '' == $name ) ? __( 'Start Date', 'woocommerce-booking' ) : $name;
	$name_checkout  = get_option( 'checkout_item-meta-date' );
	$name_checkout  = ( '' == $name_checkout ) ? __( 'End Date', 'woocommerce-booking' ) : $name_checkout;
	$name_time_slot = get_option( 'book_item-meta-time' );
	$name_time_slot = ( '' == $name_time_slot ) ? __( 'Booking Time', 'woocommerce-booking' ) : $name_time_slot;

	$labels = array( $name, $name_checkout, $name_time_slot );

	$extra_data = '';
	foreach ( $formatted_meta_data as $key => $value ) {
		if ( ! in_array( $value->key, $labels ) ) {
			$extra_data .= '
' .  $value->display_key . ' : ' . $value->display_value;
		}
	}

	$description = str_replace(
		array( 'ADDITIONAL_DATA' ),
		array( $extra_data ),
		$description
	);

	return $description;
}
add_filter( 'bkap_google_event_description', 'bkap_google_event_description_callback', 10, 2 );

How can you display the date in the reminder email based on the date format set in the WordPress General Settings?

Hook:
get_bkap_booking_item_meta_details:

Usage:

add_filter( 'get_bkap_booking_item_meta_details', 'get_bkap_booking_item_meta_details', 10, 2 );

Parameters: 2

Example:

function get_bkap_booking_item_meta_details( $booking_object, $item_id ) {

	$wp_date_format = get_option('date_format');
	$booking_object->item_booking_date = date( $wp_date_format, strtotime( $booking_object->item_hidden_date ) );
	return $booking_object;
}
add_filter( 'get_bkap_booking_item_meta_details', 'get_bkap_booking_item_meta_details', 10, 2 );

How can you change the Duration Multiplier text on the front end?

Hook:
bkap_hour_min_text_for_duration_field:

Usage:

add_filter( 'bkap_hour_min_text_for_duration_field', 'bkap_hour_min_text_for_duration_field', 10, 5 );

Parameters: 5

Example:

/** 
 * Changing x 30 Minute(s) text for duration based time.
 *
 * @param string $into_hr_min Original String.
 * @param string $duration Duration Value.
 * @param string $duration_type Duration Type.
 * @param int    $product_id Product ID.
 * @param array  $bkap_setting Booking Settings.
 */
function bkap_hour_min_text_for_duration_field( $into_hr_min, $duration, $duration_type, $product_id, $bkap_setting ){
	$into_hr_min = sprintf( __( '%1$s %2$s', 'woocommerce-booking' ), $duration, $duration_type );
	return $into_hr_min;
}
add_filter( 'bkap_hour_min_text_for_duration_field', 'bkap_hour_min_text_for_duration_field', 10, 5 );

How can you change Time slots format in the dropdown?

Hook:
bkap_time_slot_filter_after_chronological:

Usage:

add_filter( 'bkap_time_slot_filter_after_chronological', 'bkap_time_slot_filter_after_chronological', 10, 1 );

Parameters: 1

Example:

/** 
 * Changing time slots format on the front end dropdown.
 *
 * @param array $timeslots Array of Time Slots.
 * @todo - This option is not working with the Timezone option enabled.
 */
function bkap_time_slot_filter_after_chronological( $timeslots ) {

	foreach ( $timeslots as $key => $value ) {

		$explode_time = explode( ' - ', $value );
		$time         = date( 'g.ia', strtotime( $explode_time[0] ) );

		if ( isset( $explode_time[1] ) ) {
			$to_time = date( 'g.ia', strtotime( $explode_time[1] ) );
			$time    = $time . ' - ' . $to_time;
		}

		$timeslots[ $key ] = $time;
	}
	return $timeslots;
}
add_filter( 'bkap_time_slot_filter_after_chronological', 'bkap_time_slot_filter_after_chronological', 10, 1 );

How can you exclude bookings from the list on the WC Vendor front-end dashboard?

Hook:
bkap_vendor_booking_data_args:

Usage:

add_filter( 'bkap_vendor_booking_data_args', 'bkap_vendor_booking_data_args_callback', 10, 4 );

Parameters: 4

Example:

/** 
 * Exclude imported bookings being listed on Wc Vendor Front end dashboard.
 */

function bkap_vendor_booking_data_args_callback( $args ){

	$args['exclude'] = bkap_exclude_imported_bookings();

	return $args;
}
add_filter( 'bkap_vendor_booking_data_args', 'bkap_vendor_booking_data_args_callback', 10, 4 );

function bkap_exclude_imported_bookings() {

	$booking_ids = array();

	$args = array(
		'post_type'   => 'shop_order',
		'numberposts' => -1,
		'post_status' => array( 'all' ),
		'meta_key'    => '_created_via',
		'meta_value'  => 'GCal'
	);

	$posts_data = get_posts( $args );
	foreach ( $posts_data as $key => $value ) {
		$bookings = bkap_common::get_booking_ids_from_order_id( $value->ID );
		foreach ( $bookings as $k => $v) {
			$booking_ids[] = $v;
		}
	}
	return $booking_ids;
}

How can you make the non-bookable product price either repeatable or non-repeatable with multiple days in a bundled parent product?

Hook:
bkap_bundle_ignore_nonbookable_child_prices:

Usage:

add_filter( 'bkap_bundle_ignore_nonbookable_child_prices', 'bkap_restrict_bundles_nbp_prices_to_repeat' );

Parameters: None

Example:

add_filter( 'bkap_bundle_ignore_nonbookable_child_prices', 'bkap_restrict_bundles_nbp_prices_to_repeat' );

function bkap_restrict_bundles_nbp_prices_to_repeat() {
	return false;
}

How can you make the product booking setting filterable when listing availability duration time slots?

Hook:
bkap_product_duration_settings:

Usage:

add_filter( 'bkap_product_duration_settings', 'bkap_product_duration_settings_filters_cb', 10, 3 );

Parameters: 3

Example:

/** 
 * When listing availability duration time slots, Filtering the Booking settings according to the selected date.
 *
 * @param array $booking_settings Booking Settings.
 * @param int   $product_id Product ID.
 */
function bkap_product_duration_settings_filters_cb( $booking_settings, $product_id, $selected_date ) {
    if ( '16107' ==  $product_id ) { // change product id according to your product id.
        $booking_settings['bkap_duration_settings']['first_duration'] = '11:00'; // This will change the front time to 11:00 for 16107 product.
        // Write you code here to filter $product_settings
    }
    return $booking_settings;
}
add_filter( 'bkap_product_duration_settings', 'bkap_product_duration_settings_filters_cb', 10, 3 );

How can you make the product booking setting filterable when fetching it from the database?

Hook:
bkap_product_settings:

Usage:

add_filter( 'bkap_product_settings', 'bkap_product_settings_filters_cb', 10, 2 );

Parameters: 2

Example:

/** 
 * Filtering the Booking Settings.
 *
 * @param array $product_settings Booking Settings.
 * @param int   $pproduct_id Product ID.
 */
// Filter is defined in file : bkap-process-functions.php inside function: bkap_setting
function bkap_product_settings_filters_cb( $product_settings, $product_id ) {
	if ( '15903' == $product_id ) { // Change 15903 to your product id.
		$product_settings['booking_date_lockout'] = 100; // This will set the Maximum Booking for multiple nights products to 100.
		// Write you code here to filter $product_settings.
    }
    return $product_settings;
}
add_filter( 'bkap_product_settings', 'bkap_product_settings_filters_cb', 10, 2 );

How can you hide the Booking Types on the front end?

Hook:
bkap_show_date_time_booking_type, bkap_show_multiple_dates_booking_type, bkap_get_booking_types:

Usage:

add_filter( 'bkap_show_date_time_booking_type', 'bkap_show_date_time_booking_type', 10, 3 );

Parameters: 3

add_filter( 'bkap_show_multiple_dates_booking_type', 'bkap_show_multiple_dates_booking_type', 10, 3 );

Parameters: 3

add_filter( 'bkap_get_booking_types', 'bkap_get_booking_types', 10, 1 );

Parameters: 1

Example:

/**
 * This function will remove the Date & Time Booking Type from front end Booking Meta Box.
 *
 * @param bool  $show True for showing the Date & Time Booking Type.
 * @param int   $product_id Product ID.
 * @param array $booking_settings Booking Settings.
 */
function bkap_show_date_time_booking_type( $show, $product_id, $booking_settings ) {

	if ( ! is_admin() ) { // front end.
		$show = false;
	}
	return $show;
}
add_filter( 'bkap_show_date_time_booking_type', 'bkap_show_date_time_booking_type', 10, 3 );

/**
 * This function will remove the Multiple Dates Booking Type from front end Booking Meta Box.
 *
 * @param bool  $show True for showing the Date & Time Booking Type.
 * @param int   $product_id Product ID.
 * @param array $booking_settings Booking Settings.
 */
function bkap_show_multiple_dates_booking_type( $show, $product_id, $booking_settings ) {

	if ( ! is_admin() ) { // front end.
		$show = false;
	}
	return $show;
}
add_filter( 'bkap_show_multiple_dates_booking_type', 'bkap_show_multiple_dates_booking_type', 10, 3 );

/**
 * This function will remove the Multiple Nights booking type from dropdown.
 *
 * @param array $booking_types Array of Booking Types.
 */
function bkap_get_booking_types( $booking_types ) {

	if ( ! is_admin() && $booking_types['multiple_days'] ) {
		unset( $booking_types['multiple_days'] );
	}

	return $booking_types;
}
add_filter( 'bkap_get_booking_types', 'bkap_get_booking_types', 10, 1 );

How can you change the Calendar Icon of the Date Selection Field?

Hook:
bkap_calendar_icon_file:

Usage:

add_filter( 'bkap_calendar_icon_file', 'bkap_calendar_custom_icon_file' );

Parameters: None

Example:

/**
 * This function will change the calendar icon of the Date selection fields in the front-end booking form.
 */
function bkap_calendar_custom_icon_file() {    
    return 'https://www.pngfind.com/pngs/m/681-6816950_small-calendar-icon-png-transparent-png.png';
}
add_filter( 'bkap_calendar_icon_file', 'bkap_calendar_custom_icon_file' );

How can you apply a discount if the check-in date is set to a specified number of days after the current date?

Hook:
bkap_addon_add_cart_item_data:

Usage:

add_filter( 'bkap_addon_add_cart_item_data', 'bkap_addon_add_cart_item_data', 10, 6 );

Parameters: 6

Example:

/**
 * 50% discount if the check-in date is 4 days after the current date.
 *
 * @param array  $cart_arr Cart Array.
 * @param int    $product_id Product ID.
 * @param int    $variation_id Variation ID.
 * @param array  $cart_item_meta Cart Item Array.
 * @param array  $booking_settings Booking Settings.
 * @param object $global_settings Global Booking Settings.
 * 
 * @return array $cart_arr Cart Array.
 */
function bkap_addon_add_cart_item_data( $cart_arr, $product_id, $variation_id, $cart_item_meta, $booking_settings, $global_settings ) {
	$hidden_date   = $cart_arr['hidden_date'];
	$current_time  = current_time( 'timestamp' );
	$current_date  = date( 'j-n-Y', $current_time );
	$booking_date  = new DateTime( $hidden_date );
	$checkout_date = new DateTime( $current_date );
	$difference    = $checkout_date->diff( $booking_date );
	if ( $difference->d > 4 ) { // if checking date is after 4 days. 
		$cart_arr['price'] = $cart_arr['price'] / 2; // 50% discount.
	}
	return $cart_arr;
}
add_filter( 'bkap_addon_add_cart_item_data', 'bkap_addon_add_cart_item_data', 10, 6 );

How can the price display be shifted to appear after the availability message section on the product page?

Hook:
bkap_after_availability_message, bkap_after_booking_box_form:

Usage:

add_action( 'bkap_after_availability_message', 'bkap_after_availability_message', 10, 3 );

Parameters: 3

remove_action( 'bkap_after_booking_box_form', 'bkap_price_display' );

Parameters: None

Example:

/**
 * 50% discount if the checkin date is 4 days after the current date.
 *
 * @param int    $product_id Product ID.
 * @param array  $booking_settings Booking Settings.
 * @param string $booking_type Booking Type.
 *
 * @todo Convert html to template so that it can be customized.
 */
function bkap_after_availability_message( $product_id, $booking_settings, $booking_type ) {

	do_action( 'bkap_before_price_display' );

	$display_price = get_option( 'book_price-label' );

	$display_html = '

‘; $price_display = apply_filters( ‘bkap_price_display_html’, $display_html, $display_price ); echo $price_display; do_action( ‘bkap_after_price_display’ ); } add_action( ‘bkap_after_availability_message’, ‘bkap_after_availability_message’, 10, 3 ); remove_action( ‘bkap_after_booking_box_form’, ‘bkap_price_display’ );


How can the Customer Name be appended to the Event Title on the Calendar View page?

Hook:
bkap_product_name_calendar_title:

Usage:

add_filter( 'bkap_product_name_calendar_title', 'bkap_product_name_calendar_title', 10, 2 );

Parameters: 2

Example:

/**
 * Appending Customer Name to the Event Title.
 *
 * @param string $product_name Product Name.
 * @param object $booking Booking Object.
 */
function bkap_product_name_calendar_title( $product_name, $booking ) {

	$customer = $booking->get_customer();

	if ( $customer->email && $customer->name ) {
		$product_name .= ', ' . esc_html( $customer->name );
	}

	return $product_name;
}
add_filter( 'bkap_product_name_calendar_title', 'bkap_product_name_calendar_title', 10, 2 );

How can you validate if the selected number of days is greater than or equal to the previous number of nights?

Hook:
bkap_before_rescheduling_booking:

Usage:

add_action( 'bkap_before_rescheduling_booking', 'bkap_before_rescheduling_booking', 10, 10 );

Parameters: 10

Example:

/**
 * Validating if selected number of days is greater & equals to previous number of nights.
 *
 * @param int    $order_id Order ID.
 * @param int    $item_id Item ID.
 * @param obj    $item_obj Item Object.
 * @param int    $product_id Product ID.
 * @param array  $booking_data Array of Booking Data.
 * @param int    $booking_id Booking ID.
 * @param int    $quantity Quantity.
 * @param string $page Page.
 * @param int    $key Item Key.
 * @param array  $additional_data Additional Data.
 */
function bkap_before_rescheduling_booking( $order_id, $item_id, $item_obj, $product_id, $booking_data, $booking_id, $quantity, $page, $key, $additional_data ) {

	if ( isset( $booking_data['hidden_date_checkout'] ) && '' !== $booking_data['hidden_date_checkout'] ) {
		$new_start_date = $booking_data['hidden_date'];
		$new_end_date   = $booking_data['hidden_date_checkout'];

		$newdate1    = new DateTime( $new_start_date );
		$newdate2    = new DateTime( $new_end_date );
		$newinterval = $newdate1->diff( $newdate2 );
		$new_days    = $newinterval->d;

		$booking   = new BKAP_Booking( $booking_id );
		$old_start = date( 'Y-m-d', strtotime( $booking->get_start() ) );
		$old_end   = date( 'Y-m-d', strtotime( $booking->get_end() ) );

		$olddate1    = new DateTime( $old_start );
		$olddate2    = new DateTime( $old_end );
		$oldinterval = $olddate1->diff( $olddate2 );
		$old_days    = $oldinterval->d;

		if ( $new_days < $old_days ) { $message = sprintf( __( 'Please select Booking range more than %s days', 'woocommerce-booking' ), $old_days ); wp_send_json( array ( 'bkap_error' => $message ) );
			wp_die();
		}
	}
}
add_action( 'bkap_before_rescheduling_booking', 'bkap_before_rescheduling_booking', 10, 10 );

How can you perform a search based on the Category Page?

Hook:
bkap_change_search_result_page, pre_get_posts:

Usage:

add_filter( 'bkap_change_search_result_page', 'bkap_change_search_result_page', 10, 1 );

Parameters: 1

add_action( 'pre_get_posts', 'bkap_generate_bookable_data_category', 21 );

Parameters: 1

Example:

/**
 * This function will change the shop url to the category page url.
 */
function bkap_change_search_result_page( $shop_url ) {

	if ( is_product_category() ) {
		$category    = get_queried_object();
		$category_id = $category->term_id;
		$shop_url    = get_permalink( $category_id );
	}

	return $shop_url;
}
add_filter( 'bkap_change_search_result_page', 'bkap_change_search_result_page', 10, 1 );

/**
 * This function will update the taxonomy query according to the category page.
 * So that only the products will be displayed according to the category page.
 */
function bkap_generate_bookable_data_category( $query ) {

	if ( is_product_category() ) {
		$category    = get_queried_object();
		$category_id = $category->term_id;
		$tax_query[] = array(
			'taxonomy' => 'product_cat',
			'field'    => 'id',
			'terms'    => array( $category_id ),
			'operator' => 'IN',
		);

		$query->set( 'tax_query', $tax_query );
	}
}
add_action( 'pre_get_posts', 'bkap_generate_bookable_data_category', 21 );

How can you calculate the multiple dates selection combined price based on the selected dates?

Hook:
bkap_modify_product_price:

Usage:

add_filter( 'bkap_modify_product_price', 'bkap_modify_product_price', 10, 1 );

Parameters: 1

Example:

function bkap_modify_product_price( $cart_item ) {
	$product_id                 = $cart_item['product_id'];
	$multiple_dates_range_price = array(
		'16270' => array( // Key : Product ID | Value : array of range and its price.
			'2' => '150',
			'3' => '170',
			'4' => '200',
			'5' => '225',
		),
	);
	if ( in_array( $product_id, array_keys( $multiple_dates_range_price ) ) ) { // Added product id present in array?
		$booking_count = count( $cart_item['bkap_booking'] );
		if ( isset( $multiple_dates_range_price[ $product_id ][ $booking_count ] ) ) { // Has data for added number of dates.
			$price = $multiple_dates_range_price[ $product_id ][ $booking_count ];
		}
	}
	if ( isset( $price ) ) {
		$cart_item['data']->set_price( $price );
	}
	return $cart_item;
}
add_filter( 'bkap_modify_product_price', 'bkap_modify_product_price', 10, 1 );

How can the Booking Price Be Modified Based on the Selected Variation and Fixed Block?

Hook:
bkap_custom_price_for_fixed_block:

Usage:

add_filter( 'bkap_custom_price_for_fixed_block', 'bkap_custom_price_for_fixed_block', 10, 6 );

Parameters: 6

Example:

/**
 * This will modify the variation price based on the selected variation and fixed block.
 *
 * @param string $price Price.
 * @param int    $product_id Product ID.
 * @param int    $variation_id Variation ID.
 * @param string $product_type Type of Product.
 * @param string $checkin_date Check-in Date.
 * @param string $checkout_date Check-out Date.
 */
function bkap_custom_price_for_fixed_block( $price, $product_id, $variation_id, $product_type, $checkin_date, $checkout_date ) {

	if ( '' != $variation_id ) {

		$number_of_days = strval( $_POST['diff_days'] );
		$var_id         = strval( $variation_id );
		$custom_price   = array(
			'1950' => array( '14' => 1890, '30' => 3690 ), // 1950 - Variation ID of Home Page & Articles.
			'1951' => array( '14' => 1360, '30' => 2590 ), // 1951 - Variation ID of Job Listings.
			'1952' => array( '14' => 1360, '30' => 2590 ), // 1952 - Variation ID of Professtional Networking.
		);

		if ( isset( $custom_price[ $variation_id ][ $number_of_days ] ) ) { // check if variation price is set for selected number of days.
			$price = $custom_price[ $variation_id ][ $number_of_days ];
		}
	}

	return $price;
}
add_filter( 'bkap_custom_price_for_fixed_block', 'bkap_custom_price_for_fixed_block', 10, 6 );

How can you enable all weekdays for all bookable products?

Hook:
bkap_change_postcode_weekdays:

Usage:

add_filter( 'bkap_change_postcode_weekdays', 'bkap_change_postcode_weekdays', 10, 3 );

Parameters: 3

Example:

/**
 * This function will enable all the weekdays for all products.
 *
 * @param array  $postcode_weekdays Emtpy Array.
 * @param int    $product_id Product ID.
 * @param string $default Recurring Option value
 *
 * @return array Array of Recurring Weekdays.
 */
function bkap_change_postcode_weekdays( $postcode_weekdays, $product_id, $default ) {

	/* 
	$product_ids = array( '123', '456' ); // Here you can give array of Product Ids if you want to enable all the weekdays for specific products.
	if ( ! in_array( $product_id, $product_ids ) ) {
		return $postcode_weekdays;
	}
	*/

	$postcode_weekdays = array(
		'booking_weekday_0' => 'on',
		'booking_weekday_1' => 'on',
		'booking_weekday_2' => 'on',
		'booking_weekday_3' => 'on',
		'booking_weekday_4' => 'on',
		'booking_weekday_5' => 'on',
		'booking_weekday_6' => 'on',
	);

	return $postcode_weekdays;
}
add_filter( 'bkap_change_postcode_weekdays', 'bkap_change_postcode_weekdays', 10, 3 );

How can you override the Product level settings with Global Settings for canceling bookings?

Hook:
bkap_cancel_booking_set_global_level_precedence:

Usage:

add_filter( 'bkap_cancel_booking_set_global_level_precedence', 'set_global_level_precedence', 10, 3 );

Parameters: 3

Example:

/**
 * Cancel Booking: This function will override the Product Level Settings (if available) and Set the Global Level Settings as a priority - this is required because, by default, Product Level Settings has a higher precedence than Global Level Settings.
 *
 * @param boolean  $status Status of Product Level Setting.
 * @param int      $booking_id Booking ID.
 * @param object   $booking Booking Object.
 *
 * @return boolean New Status to set precedence for Global Level.
 */
function set_global_level_precedence( $status, $booking_id, $booking ) {
	return true;
}
add_filter( 'bkap_cancel_booking_set_global_level_precedence', 'set_global_level_precedence', 10, 3 );

How can you Exclude Product from Cancel Booking?

Hook:
bkap_cancel_booking_exclude_product:

Usage:

add_filter( 'bkap_cancel_booking_exclude_product', 'exclude_product_at_global_level', 10, 4 );

Parameters: 4

Example:

/**
 * Cancel Booking: This function will exclude the Product from Cancel Booking Feature even if it has Settings at Product Level or Global Level.
 *
 * @param boolean  $status Status of Product Level Setting.
 * @param int      $product_id Product ID.
 * @param int      $booking_id Booking ID.
 * @param object   $booking Booking Object.
 *
 * @return boolean New Status to set precedence for Global Level.
 */
function exclude_product_at_global_level( $status, $product_id, $booking_id, $booking ) {
	return true;
}
add_filter( 'bkap_cancel_booking_exclude_product', 'exclude_product_at_global_level', 10, 4 );

How can you show only the Fixed Time Booking Type?

Hook:
bkap_get_booking_types:

Usage:

add_filter( 'bkap_get_booking_types', 'limit_booking_types_to_fixed', 10, 1 );

Parameters: 1

Example:

/**
 * This function removes all other booking types and shows only the Fixed Time Booking type.
 */

function limit_booking_types_to_fixed( $booking_types ) {
     $booking_types = array(); // Clear previous contents of variable.
	 $booking_types['date_time'] = array(
		'key'   => 'date_time',
		'label' => 'Fixed Time',
                'group' => 'Date & Time',
	);
	 return $booking_types;
}

add_filter( 'bkap_get_booking_types', 'limit_booking_types_to_fixed', 10, 1 );

How can you display the Price x No. of Days calculation in the cart and checkout.?

Hook:
woocommerce_cart_item_subtotal:

Usage:

add_filter( 'woocommerce_cart_item_subtotal', 'bkap_woocommerce_cart_item_subtotal', 10, 3 );

Parameters: 3

Example:

function bkap_woocommerce_cart_item_subtotal( $product_subtotal, $cart_item, $cart_item_key ) {

	if ( isset( $cart_item['bkap_booking'] ) ) {
		
		$booking = $cart_item['bkap_booking'][0];
		if ( isset( $booking[ 'hidden_date_checkout' ] ) ) {
			$checkin_date_str  = strtotime( $booking[ 'hidden_date' ] );
			$checkout_date_str = strtotime( $booking[ 'hidden_date_checkout' ] );
			$checkin_date      = date( 'Y-m-d', $checkin_date_str );
			$checkout_date     = date( 'Y-m-d', $checkout_date_str );
			$number_of_days    = $checkout_date_str - $checkin_date_str;
			$no_of_nights      = floor( $number_of_days / 86400 );
			$per_day_price     = $booking[ 'price' ] / $no_of_nights;
			$product_subtotal = wc_price( $per_day_price ) . ' x ' . $no_of_nights . ' nights = ' . $product_subtotal;
		}
	}
	return $product_subtotal;
}
add_filter( 'woocommerce_cart_item_subtotal', 'bkap_woocommerce_cart_item_subtotal', 10, 3 );

How can you enable auto-refunds for bookings canceled by customers?

Hook:
bkap_process_refund_for_booking:

Usage:

add_filter( 'bkap_process_refund_for_booking', 'bkap_process_refund_for_booking', 10, 3 );

Parameters: 3

Example:

function bkap_process_refund_for_booking( $status, $booking_id, $order_id ) {
	return true;
}
add_filter( 'bkap_process_refund_for_booking', 'bkap_process_refund_for_booking', 10, 3 );

How can you change Holiday label to Unavailable?

Hook:
bkap_change_hover_text_for_disabled_dates:

Usage:

add_filter( 'bkap_change_hover_text_for_disabled_dates', 'bkap_change_hover_text_for_disabled_dates', 10, 1 );

Parameters: 1

Example:

function bkap_change_hover_text_for_disabled_dates( $datepicker_tips ) {

    $datepicker_tips['holiday_label'] = __( 'Unavailable', 'woocommerce-booking' );
    return $datepicker_tips;
}
add_filter( 'bkap_change_hover_text_for_disabled_dates', 'bkap_change_hover_text_for_disabled_dates', 10, 1 );

How can you allow the Editor to View Booking and Calendar View ?

Hook:
bkap_register_post_type_bkap_gcal_event, bkap_register_post_type_bkap_booking, user_has_cap:

Usage:

add_filter( 'bkap_register_post_type_bkap_gcal_event', 'bkap_register_post_type_bkap_booking', 10, 1 );

Parameters: 1

add_filter( 'bkap_register_post_type_bkap_booking', 'bkap_register_post_type_bkap_booking', 10, 1 );

Parameters: 1

add_filter( 'user_has_cap', 'allow_user_to_edit_cpt_filter', 100, 3 );

Parameters: 3

Example:

function bkap_register_post_type_bkap_booking( $data ) {

	$data['capability_type'] = 'post';

	return $data;
}
add_filter( 'bkap_register_post_type_bkap_gcal_event', 'bkap_register_post_type_bkap_booking', 10, 1 );
add_filter( 'bkap_register_post_type_bkap_booking', 'bkap_register_post_type_bkap_booking', 10, 1 );

function allow_user_to_edit_cpt_filter( $capauser, $capask, $param ) {

	$user      = wp_get_current_user();
	$user_role = $user->roles;

	if ( in_array( 'editor', $user_role ) && count( $user_role ) == 1 ) {
		if ( isset( $_GET['booking_view'] ) && 'booking_calender' == $_GET['booking_view'] ) {
			$capauser['manage_woocommerce'] = 1;
		} else {
			$capauser['manage_woocommerce'] = 0;
		}
	}

    return $capauser;
}
add_filter( 'user_has_cap', 'allow_user_to_edit_cpt_filter', 100, 3 );

How can you change for the Requires Confirmation setting?

Hook:
bkap_get_validate_add_cart_item_before:

Usage:

add_action( 'bkap_get_validate_add_cart_item_before', 'bkap_get_validate_add_cart_item_before', 10, 3 );

Parameters: 3

Example:

function bkap_get_validate_add_cart_item_before( $product_id, $booking_settings, $product ){

    $product_requires_confirmation = bkap_common::bkap_product_requires_confirmation( $product_id ); // check if the product being added requires confirmation.
    $cart_requires_confirmation    = bkap_common::bkap_cart_requires_confirmation(); // check if the cart contains a product that requires confirmation.
    $is_bookable      = bkap_common::bkap_get_bookable_status( $product_id );
    
    if ( ! $is_bookable && $cart_requires_confirmation ) {
        // remove existing products.
        WC()->cart->empty_cart();

        // add a notice.
        $message = bkap_get_book_t( 'book.conflicting-products' );
        wc_add_notice( __( $message, 'woocommerce-booking' ), $notice_type = 'notice' );
    }
}
add_action( 'bkap_get_validate_add_cart_item_before', 'bkap_get_validate_add_cart_item_before', 10, 3 );

How can you ensure that weekdays are not disabled in the checkout calendar?

Hook:
bkap_add_additional_data:

Usage:

add_filter( 'bkap_add_additional_data', 'bkap_add_additional_data', 10, 3 );

Parameters: 3

Example:

function bkap_add_additional_data( $additional_data, $booking_settings, $product_id ) {

	$allowed_weekdays = array(
		//'0', // Sunday
		'1', // Monday.
		//'2', // Tuesday
		//'3', // Wednesday
		//'4', // Thursday
		//'5', // Friday
		//'6', // Saturday
	);

	if ( isset( $additional_data['wapbk_block_checkout_weekdays'] ) && '' !== $additional_data['wapbk_block_checkout_weekdays'] ) {
		$checkout_days = explode( ',', $additional_data['wapbk_block_checkout_weekdays'] );

		foreach ( $allowed_weekdays as $a_w_key => $a_w_value ) {
			if ( ( $key = array_search( $a_w_value, $checkout_days ) ) !== false ) {
				unset( $checkout_days[ $key ] );
			}
		}

		if ( ! empty( $checkout_days ) ) {
			if ( count( $checkout_days ) > 1 ) {
				$additional_data['wapbk_block_checkout_weekdays'] = implode( ',', $checkout_days );
			} else {
				$checkout_days                                    = array_values( $checkout_days );
				$additional_data['wapbk_block_checkout_weekdays'] = $checkout_days[0];
			}
		} else {
			$additional_data['wapbk_block_checkout_weekdays'] = '';
		}
	}
	return $additional_data;
}
add_filter( 'bkap_add_additional_data', 'bkap_add_additional_data', 10, 3 );

How can you disable the fixed block booking on the admin end so that the admin can modify the booking details regardless of the fixed blocks added to the product?

Hook:
bkap_init_parameter_localize_script_booking_settings, bkap_custom_price_for_fixed_block, bkap_show_fixed_blocks_field:

Usage:

add_filter( 'bkap_init_parameter_localize_script_booking_settings', 'bkap_init_parameter_localize_script_booking_settings', 1 );

Parameters: 1

add_filter( 'bkap_custom_price_for_fixed_block', 'bkap_custom_price_for_fixed_block', 10, 6 );

Parameters: 6

add_filter( 'bkap_show_fixed_blocks_field', 'bkap_show_fixed_blocks_field' );

Parameters: None

Example:

/**
 * Disable the Fixed Block Booking on the admin end.
 */
function bkap_init_parameter_localize_script_booking_settings( $booking_settings ) {

	$booking_settings['booking_fixed_block_enable'] = '';
	$booking_settings['bkap_fixed_blocks_data']     = array();

	return $booking_settings;
}
add_filter( 'bkap_init_parameter_localize_script_booking_settings', 'bkap_init_parameter_localize_script_booking_settings', 1 );

/**
 * This function will calculate the price based on the custom number of days selected when fixed blocks are disabled for admin end using filter.
 */
function bkap_custom_price_for_fixed_block( $price, $product_id, $variation_id, $product_type, $checkin_date, $checkout_date ) {

	if ( '' == $price ) {

		$result = get_post_meta( $product_id, '_bkap_fixed_blocks_data', true );
		$days = $_POST['diff_days'];
		if ( count( $result ) > 0 ) {
			foreach ($result as $key => $value) {
				$fixed_block_days = $value['number_of_days'];

				if ( $days == $fixed_block_days ) {	
					$price = $value['price'];
					$found = true;
					break;
				}
			}
		}

		if ( ! isset( $found ) ) {

			$product       = wc_get_product( $product_id );
			$product_price = $product->get_price();
			$price 	       = $product_price * $days;
		}
	}

	return $price;
}
add_filter( 'bkap_custom_price_for_fixed_block', 'bkap_custom_price_for_fixed_block', 10, 6 );

function bkap_show_fixed_blocks_field(){

    return false;
}
add_filter( 'bkap_show_fixed_blocks_field', 'bkap_show_fixed_blocks_field' );

How can you add the Special Price to Variable Price?

Hook:
bkap_modify_booking_price:

Usage:

add_filter( 'bkap_modify_booking_price', 'bkap_add_special_price_to_variation', 10, 4 );

Parameters: 4

Example:

/**
 * Adding Special Price to Variable Price.
 *
 * @param string $time_slot_price Booking Price.
 * @param string $product_id Product ID.
 * @param string $variation_id Variable ID.
 * @param string $product_type Product type.
 *
 * @return string $time_slot_price Modified Booking Price.
 */
function bkap_add_special_price_to_variation( $time_slot_price, $product_id, $variation_id, $product_type ) {

	if ( isset( $_POST['special_booking_price'] ) && '' != $_POST['special_booking_price'] ) {
		$time_slot_price = bkap_common::bkap_get_price( $product_id, $variation_id, $product_type );
		$time_slot_price +=	$_POST['special_booking_price'];
	}
	return $time_slot_price;
}
add_filter( 'bkap_modify_booking_price', 'bkap_add_special_price_to_variation', 10, 4 );

How can you show the pending confirmation events in Calendar View?

Hook:
bkap_calendar_view_events_args:

Usage:

add_filter( 'bkap_calendar_view_events_args', 'bkap_calendar_view_events_args', 10, 1 );

Parameters: 1

Example:

/**
 * Show pending confirmation bookings on the Calendar View.
 *
 * @param array $args Array of arguments to pass to get_posts.
 *
 * @return array $args Array of arguments to pass to get_posts.
 */
function bkap_calendar_view_events_args( $args ) {

	$args['post_status'] = array( 'pending-confirmation', 'paid', 'confirmed' );

	return $args;
}
add_filter( 'bkap_calendar_view_events_args', 'bkap_calendar_view_events_args', 10, 1 );

How can you hide x 1 Hour(s) from front end Duration Based Time field?

Hook:
bkap_hour_min_text_for_duration_field:

Usage:

add_filter( 'bkap_hour_min_text_for_duration_field', 'bkap_hour_min_text_for_duration_field_callback' );

Parameters: None

Example:

function bkap_hour_min_text_for_duration_field_callback(){
	return '';
}
add_filter( 'bkap_hour_min_text_for_duration_field', 'bkap_hour_min_text_for_duration_field_callback' );

How can you make your Search widget work on the category pages?

Hook:
woocommerce_product_query:

Usage:

add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );

Parameters: 1

Example:

function custom_pre_get_posts_query( $q ) {

	if ( is_product_category() && isset( $_GET['w_checkin'] ) ) {

		$start_date = $_GET['w_checkin'];

		if ( ! empty( $_GET['w_checkout'] ) ) {
			$end_date = $_GET['w_checkout'];
		} else {
			$end_date = $_GET['w_checkin'];
		}

		if ( isset( WC()->session ) ) {
			WC()->session->set( 'start_date', $start_date );
			WC()->session->set( 'end_date', $end_date );
			if ( ! empty( $_GET['w_allow_category'] ) && $_GET['w_allow_category'] == 'on' ) {
				WC()->session->set( 'selected_category', $_GET['w_category'] );
			} else {
				WC()->session->set( 'selected_category', 'disable' );
			}

			if ( ! empty( $_GET['w_allow_resource'] ) && $_GET['w_allow_resource'] == 'on' ) {
				WC()->session->set( 'selected_resource', $_GET['w_resource'] );
			} else {
				WC()->session->set( 'selected_resource', 'disable' );
			}
		}
	}

	if ( ! empty( $start_date ) &&
		! empty( $end_date )
	) {
		$meta_query        = array();
		$filtered_products = array();
		$bookable_products = bkap_common::get_woocommerce_product_list( false, 'on', '', array(), $meta_query );

		foreach ( $bookable_products as $pro_key => $pro_value ) {

			$product_id   = $pro_value['1'];
			$view_product = bkap_check_booking_available( $product_id, $start_date, $end_date );

			if ( $view_product ) {
				array_push( $filtered_products, $product_id );
			}
		}

		$filtered_products = apply_filters( 'bkap_additional_products_search_result', $filtered_products );

		if ( count( $filtered_products ) === 0 ) {
			$filtered_products = array( '' );
		}

		$q->set( 'post__in', $filtered_products );
	}
}
add_action( 'woocommerce_product_query', 'custom_pre_get_posts_query' );

How can you remove the Bookings menu from the My Accounts page?

Hook:
woocommerce_account_menu_items:

Usage:

add_filter( 'woocommerce_account_menu_items', 'bkap_remo_booking_endpoint', 20, 1 );

Parameters: 1

Example:

/**
 * Remove the Bookings menu from the My Accounts page
 *
 * @param array $menu My Account Menu.
 */
function bkap_remo_booking_endpoint( $menu ) {

	unset( $menu['bookings'] );

	return $menu;
}
add_filter( 'woocommerce_account_menu_items', 'bkap_remo_booking_endpoint', 20, 1 );

How can you add Email Address Column on View Bookings, CSV and Print?

Hook:
bkap_view_booking_columns, bkap_view_booking_column_data, bkap_view_booking_individual_data, bkap_bookings_csv_columns, bkap_bookings_csv_individual_row_data, bkap_view_bookings_print_individual_row_data:

Usage:

add_filter( 'bkap_view_booking_columns', 'bkap_view_booking_columns', 10, 1 );

Parameters: 1

add_filter( 'bkap_view_booking_column_data', 'bkap_view_booking_column_data', 10, 2 );

Parameters: 2

add_filter( 'bkap_view_booking_individual_data', 'bkap_view_booking_individual_data', 10, 3 );

Parameters: 3

add_filter( 'bkap_bookings_csv_columns', 'bkap_bookings_csv_columns', 10, 1 );

Parameters: 1

add_filter( 'bkap_bookings_csv_individual_row_data', 'bkap_bookings_csv_individual_data', 10, 4 );

Parameters: 4

add_filter( 'bkap_view_bookings_print_individual_row_data', 'bkap_view_bookings_print_individual_row_data', 10, 4 );

Parameters: 4

Example:

/* Adding Column on View Bookings */
function bkap_view_booking_columns( $columns ) {

	$additional_columns = array( 'bkap_customer_email' => __( 'Email Address', 'woocommerce-booking' ) );
	// Adding column after Booked by hence 5.
	$columns = array_slice( $columns, 0, 5, true ) + $additional_columns + array_slice( $columns, 5, count( $columns ) - 5, true );

	return $columns;
}
add_filter( 'bkap_view_booking_columns', 'bkap_view_booking_columns', 10,  );

function bkap_view_booking_column_data( $column, $data ) {

	switch ( $column) {
		case 'bkap_customer_email':
			echo $data['bkap_customer_email'];
			break;
		default:
			# code...
			break;
	}
}
add_filter( 'bkap_view_booking_column_data', 'bkap_view_booking_column_data', 10, 2 );

/* Tyche Softwares: Adding Booking Data on View Bookings page */
function bkap_view_booking_individual_data( $booking_data, $booking, $booking_id ) {

	$booking_obj    = new BKAP_Booking( $booking_id );
	$customer       = $booking_obj->get_customer();
	$customer_email = $customer->email;

	$booking_data['bkap_customer_email'] = $customer_email;

	return $booking_data;

}
add_filter( 'bkap_view_booking_individual_data', 'bkap_view_booking_individual_data', 10, 3 );

/* Adding column to CSV and Print */
function bkap_bookings_csv_columns( $columns ) {
	$additional_columns = array( 'bkap_customer_email' => __( 'Email Address', 'woocommerce-booking' ) );
	// Adding column after Booked by hence 4.
	$columns = array_slice( $columns, 0, 4, true ) + $additional_columns + array_slice( $columns, 4, count( $columns ) - 4, true );
	return $columns;
}
add_filter( 'bkap_bookings_csv_columns', 'bkap_bookings_csv_columns', 10, 1 );

/* Adding Booking Data to CSV */
function bkap_bookings_csv_individual_data( $row, $booking, $booking_id, $data ) {

	extract( $data );
	// Fetching Custom Email.
	$booking_obj    = new BKAP_Booking( $booking_id );
	$customer       = $booking_obj->get_customer();
	$customer_email = $customer->email;

	// Adding Customer Email infomration after Booked By column data.
	$row = $status . ',' . $booking_id . ',"' . $product_name . '",' . $booked_by . ',' . $customer_email . ',' . $order_id . ',"' . $start_date . '","' . $end_date . '","' . $persons . '",' . $quantity . ',' . $order_date . ',"' . $final_amt . '",' . $meeting_link;
	return $row;
}
add_filter( 'bkap_bookings_csv_individual_row_data', 'bkap_bookings_csv_individual_data', 10, 4 );

/* Adding Booking Data to Print td */
function bkap_view_bookings_print_individual_row_data( $print_data_row_data_td, $booking, $booking_id, $data ) {
	extract( $data );
	// Fetching Customer Email.
	$booking_obj    = new BKAP_Booking( $booking_id );
	$customer       = $booking_obj->get_customer();
	$customer_email = $customer->email;
	// Adding Customer Email after Booked by column data.
	$print_data_row_data_td  = '';
	$print_data_row_data_td .= '' . $status . '

‘; $print_data_row_data_td .= ‘

' . $booking->id . '

‘; $print_data_row_data_td .= ‘

' . $product_name . '

‘; $print_data_row_data_td .= ‘

' . $booked_by . '

‘; $print_data_row_data_td .= ‘

' . $customer_email . '

‘; $print_data_row_data_td .= ‘

' . $booking_obj->order_id . '

‘; $print_data_row_data_td .= ‘

' . $start_date . '

‘; $print_data_row_data_td .= ‘

' . $end_date . '

‘; $print_data_row_data_td .= ‘

' . $persons . '

‘; $print_data_row_data_td .= ‘

' . $quantity . '

‘; $print_data_row_data_td .= ‘

' . $order_date . '

‘; $print_data_row_data_td .= ‘

' . $final_amt . '

‘; $print_data_row_data_td .= ‘

' . $meeting_link . '

‘; return $print_data_row_data_td; } add_filter( ‘bkap_view_bookings_print_individual_row_data’, ‘bkap_view_bookings_print_individual_row_data’, 10, 4 );


How can you change the Number of dates to choose value for admin?

Hook:
bkap_init_parameter_localize_script_additional_data:

Usage:

add_filter( 'bkap_init_parameter_localize_script_additional_data', 'update_booking_settings', 10, 1 );

Parameters: 1

Example:

/**
 * Change the Number of dates to choose value for admin.
 *
 * @param array $additional_data Booking computation data.
 */
function update_booking_settings( $additional_data ) {

	if ( is_admin() ) {
		$additional_data['number_of_dates'] = 120; // set number of date according to requirements.
	}

	return $additional_data;
}
add_filter( 'bkap_init_parameter_localize_script_additional_data', 'update_booking_settings', 10, 1 );

How can you consider Number of dates to choose from current date?

Hook:
bkap_init_parameter_localize_script_additional_data:

Usage:

add_filter( 'bkap_init_parameter_localize_script_additional_data', 'consider_number_of_dates_from_current_date', 10, 1 );

Parameters: 1

Example:

/**
 * Consider Number of dates to choose from current date.
 *
 * @param array $additional_data Booking computation data.
 */
function consider_number_of_dates_from_current_date( $additional_data ) {

	$current_date                       = strtotime( date( 'Y-m-d', current_time( 'timestamp' ) ) );
	$default_date                       = strtotime( $additional_data['default_date'] );
	$datediff                           = $current_date - $default_date;
	$days                               = abs( round( $datediff / ( 60 * 60 * 24 ) ) );
	$additional_data['number_of_dates'] = $additional_data['number_of_dates'] - $days;

	return $additional_data;
}
add_filter( 'bkap_init_parameter_localize_script_additional_data', 'consider_number_of_dates_from_current_date', 10, 1 );

How can you hide Booking features for Vendor?

Hook:
bkap_vendor_capability_options:

Usage:

add_filter( 'bkap_vendor_capability_options', 'bkap_vendor_capability_options', 10, 1 );

Parameters: 1

Example:

function bkap_vendor_capability_options( $end_points ) {

	$disable_features = array(
		'bkap-manage-resource',
		//'bkap-list',
		//'bkap-create-booking',
		'bkap-calendar',
		//'bkap-send-reminders',
	);

	foreach ( $end_points as $key => $value ) {
		if ( in_array( $value['slug'], $disable_features ) ) {
			$end_points[ $key ]['slug'] = false;
		}
	}
	return $end_points;
}
add_filter( 'bkap_vendor_capability_options', 'bkap_vendor_capability_options', 10, 1 );

How can you change Maximum number of nights to book value for admin?

Hook:
bkap_init_parameter_localize_script_booking_settings:

Usage:

add_filter( 'bkap_init_parameter_localize_script_booking_settings', 'modify_booking_maximum_number_days_multiple', 1 );

Parameters: 1

Example:

/**
 * Change Maximum number of nights to book value for admin.
 *
 * @param array $booking_settings Booking Settings.
 */
function modify_booking_maximum_number_days_multiple( $booking_settings ) {

	if ( is_admin() ) { // backend check
		$booking_settings['booking_maximum_number_days_multiple'] = 365; // Change value 365 according to your requirements.
	}

	return $booking_settings;
}
add_filter( 'bkap_init_parameter_localize_script_booking_settings', 'modify_booking_maximum_number_days_multiple', 1 );

How can you add Book Now button Shortcode?

Hook:
bkap_book_now_button:

Usage:

add_shortcode( 'bkap_book_now_button', 'bkap_book_now_button' );

Parameters: 1

Example:

/**
 * [bkap_book_now_button start_date='2022-08-24' time_slot='10:00 - 12:00' product_id='3430' price='150' book_now_text='Book Now']
 */
function bkap_book_now_button( $atts ) {

	$booking_data = shortcode_atts( array(
		'start_date'    => '',
		'end_date'      => '',
		'time_slot'     => '',
		'product_id'    => '',
		'price'         => 0,
		'book_now_text' => 'Book Now!',
	), $atts );

	if ( '' === $booking_data['start_date'] ) {
		return '';
	}

	$start_date     = $booking_data['start_date'];
	$start_date_jny = date( 'j-n-Y', strtotime( $start_date ) );
	$time_slot      = $booking_data['time_slot'];
	$product_id     = $booking_data['product_id'];
	$price          = $booking_data['price'];
	$book_now_text  = $booking_data['book_now_text'];

	$block_assets = new BKAP_List_Booking();
	$block_assets->bkap_block_assets();
	wp_enqueue_script( 'tyche-bookable-listing' );
	wp_enqueue_style( 'tyche-list-booking' );

	return '

‘; } add_shortcode( ‘bkap_book_now_button’, ‘bkap_book_now_button’ );


How can you add Select resource option in Select Resource dropdown on the front end?

Hook:
bkap_default_resource_option_value:

Usage:

add_filter( 'bkap_default_resource_option_value', 'bkap_default_resource_option_value', 10, 1 );

Parameters: 1

Example:

function bkap_default_resource_option_value() {

	return '' . __( 'Select Resource', 'woocommerce-booking' ) . '';
}
add_filter( 'bkap_default_resource_option_value', 'bkap_default_resource_option_value', 10, 1 );

How can this script be used to allow booking when weekdays are disabled?

Hook:
bkap_global_settings:

Usage:

add_filter( 'bkap_global_settings', 'bkap_allow_disable_weekdays', 10, 1 );

Parameters: 1

Example:

/**
 * Add this code snippet in functions.php file of your currently active theme.
 * Once that is done then visit the site.
 * Visiting the site will execute this function which will allow booking 'Fixed block booking' even when weekdays are disable.
 */

function bkap_allow_disable_weekdays( $global_settings ) {
	$global_settings->allow_disable_weekdays = true;
        // Filter to exclude disable days from range and push end date.
        $global_settings->count_disable_weekdays = false;
	return $global_settings;
}
add_filter( 'bkap_global_settings', 'bkap_allow_disable_weekdays', 10, 1 );

How can you send Booking Confirmation Email After Order is Received?

Hook:
woocommerce_thankyou:

Usage:

add_action( 'woocommerce_thankyou', 'bkap_send_booking_confirmation', 10, 1 );

Parameters: 1

Example:

/**
 * This will send the Booking Confirmation email to customer even if the product is not setup with the requires confirmation option.
 *
 * @param int $order_id Order Id.
 */
function bkap_send_booking_confirmation( $order_id ) {

	if ( ! $order_id )
		return;

	// Allow code execution only once.
	if ( ! get_post_meta( $order_id, '_thankyou_action_done', true ) ) {

		// Get an instance of the WC_Order object.
		$order = wc_get_order( $order_id );
		$booking_present = false;
		// Loop through order items.
		foreach ( $order->get_items() as $item_id => $item ) {

			$booking_id = bkap_common::get_booking_id( $item_id );

			if ( $booking_id ) {
				$booking_present = true;
				$wc_email   = WC_Emails::instance();
				$email      = $wc_email->emails['BKAP_Email_Booking_Confirmed'];
				$email->trigger( $item_id, $booking_id );
				do_action( 'bkap_booking_is_confirmed', $booking_id );
			}
		}

		if ( $booking_present ) {
			// Flag the action as done (to avoid repetitions on reload for example).
			$order->update_meta_data( '_thankyou_action_done', true );
			$order->save();
		}
	}
}
add_action( 'woocommerce_thankyou', 'bkap_send_booking_confirmation', 10, 1 );

How can you create imported booking with the 0 price?

Hook:
bkap_before_creating_manual_order:

Usage:

add_filter( 'bkap_before_creating_manual_order', 'bkap_before_creating_manual_order', 10, 3 );

Parameters: 3

Example:

function bkap_before_creating_manual_order( $variations, $booking_details, $gcal ) { 
    if ( $gcal ) {         
        $variations['subtotal'] = 0;
        $variations['total']    = 0;
    }
    return $variations; 
}

add_filter( 'bkap_before_creating_manual_order', 'bkap_before_creating_manual_order', 10, 3 );

How can you use Global Time Slots Booking for the Durations Based Time?

Hook:
bkap_additional_bookings_to_be_considered:

Usage:

add_filter( 'bkap_additional_bookings_to_be_considered', 'bkap_additional_bookings_to_be_considered', 10, 3 );

Parameters: 3

Example:

/**
 * Global Time Slots Booking for the Durations Based Time.
 */
function bkap_additional_bookings_to_be_considered( $booking_idss, $product_id, $resource_id ) {

	// Getting Product ids that has Duration Based Time Booking Type.
	$args           = array(
		'post_type'      => 'product',
		'meta_query'     => array(
			array(
				'key'     => '_bkap_booking_type',
				'value'   => 'duration_time',
				'compare' => '=',
			),
		),
	);
	$duration_query = new WP_Query( $args );

	$product_ids = array();
	if ( $duration_query->have_posts() ) {
		foreach ( $duration_query->posts as $post1 ) {
			$product_ids[] = $post1->ID;
		}

		if ( ( $key = array_search( $product_id, $product_ids ) ) !== false ) {
			unset( $product_ids[ $key ] );
		}
	}

	if ( $resource_id > 0 ) {
		$meta_key   = '_bkap_resource_id';
		$meta_value = $resource_id;
	} else {
		$meta_key   = '_bkap_product_id';
		$meta_value = $product_id;
	}

	if ( count( $product_ids ) > 0 ) {
		// IF there are other products that are setup with the Duration Based Time Booking Type
		// Then fetch the bookings of those products and consider those bookings for current product.
		$args = array(
			'post_type'      => 'bkap_booking',
			'post_status'    => array( 'paid', 'pending-confirmation', 'confirmed' ),
			'posts_per_page' => -1,
			'meta_query'     => array(
				array(
					'key'     => $meta_key,
					'value'   => $product_ids,
					'compare' => 'IN',
				),
			),
		);

		$query1 = new WP_Query( $args );

		if ( $query1->have_posts() ) {
			foreach ( $query1->posts as $post1 ) {
				$booking_idss[] = $post1->ID;
			}
		}
	}

	return $booking_idss;
}
add_filter( 'bkap_additional_bookings_to_be_considered', 'bkap_additional_bookings_to_be_considered', 10, 3 );

How can you disable Booking Dates fields if searched for the available product?

Hook:
bkap_calendar_icon_file:

Usage:

add_filter( 'bkap_disable_booking_fields', 'bkap_disable_booking_fields' );

Parameters: None

Example:

/**
 * Disable Booking Dates fields if searched for the available product. - https://prnt.sc/vutOfllTPzpF
 */
function bkap_disable_booking_fields() {
	return true;
}
add_filter( 'bkap_disable_booking_fields', 'bkap_disable_booking_fields' );

How can you allow Bookable and Requires Confirmation product to cart?

Hook:
bkap_validate_conflicting_products:

Usage:

add_filter( 'bkap_validate_conflicting_products', 'bkap_validate_conflicting_products' );

Parameters: None

Example:

function bkap_validate_conflicting_products() {
	return false;
}
add_filter( 'bkap_validate_conflicting_products', 'bkap_validate_conflicting_products' );

How can you set booking fields data from the URL parameters?

Hook:
woocommerce_before_single_product:

Usage:

add_action( 'woocommerce_before_single_product', 'bkap_set_bookings_via_get' );

Parameters: None

Example:

/**
 * Setting booking fields data from the URL parameters. start and end date is passed in the URL parameters. This can be changed according to business requirements. e.g check_in and check_out.
 */
function bkap_set_bookings_via_get() {

	if ( isset( $_GET['start'] ) && isset( $_GET['end'] ) ) {

		$start_date = $_GET['start'];
		if ( ! empty( $_GET['end'] ) ) {
			$end_date = $_GET['end'];
		} else {
			$end_date = $_GET['start'];
		}

		if ( isset( WC()->session ) ) {
			WC()->session->set( 'start_date', $start_date );
			WC()->session->set( 'end_date', $end_date );
		}
	}
}
add_action( 'woocommerce_before_single_product', 'bkap_set_bookings_via_get' );

How can you set order status to processing and booking status to pending payment when creating manual booking?

Hook:
bkap_booking_status_on_create_order, bkap_manual_gcal_booking_order_status, woocommerce_order_status_changed:

Usage:

add_filter( 'bkap_booking_status_on_create_order', 'bkap_booking_status_on_create_order', 10, 1 );

Parameters: 1

add_filter( 'bkap_manual_gcal_booking_order_status', 'bkap_manual_gcal_booking_order_status', 8, 1 );

Parameters: 1

add_action( 'woocommerce_order_status_changed', 'bkap_booking_pending_to_confirmed', 8, 3 );

Parameters: 3

Example:

function bkap_booking_status_on_create_order( $status ) {

	if ( is_admin() ) {
		if ( isset( $_POST['original_post_status'] ) ) {
			return $status;
		}
		$status = 'pending-confirmation';
	}
 	return $status;
}
add_filter( 'bkap_booking_status_on_create_order', 'bkap_booking_status_on_create_order', 10, 1 );

function bkap_manual_gcal_booking_order_status( $status ) {

	if ( is_admin() ) {
		$status = 'pending';
	}
 	return $status;
}
add_filter( 'bkap_manual_gcal_booking_order_status', 'bkap_manual_gcal_booking_order_status', 8, 1 );

function bkap_booking_pending_to_confirmed( $order_id, $old_status, $new_status ) {

	if ( 'failed' !== $old_status && in_array( $new_status, array( 'processing' ), true ) ) {

		$order       = wc_get_order( $order_id );
		$order_items = $order->get_items();
		foreach ( $order_items as $item_key => $item_value ) {
			$booking_status = wc_get_order_item_meta( $item_key, '_wapbk_booking_status' );
			if ( isset( $booking_status ) && 'pending-confirmation' === $booking_status ) {
				$status = 'confirmed';
				wc_update_order_item_meta( $item_key, '_wapbk_booking_status', $status );
				$booking_id = bkap_common::get_booking_id( $item_key );
				if ( $booking_id ) {
					$new_booking = bkap_checkout::get_bkap_booking( $booking_id );
					$new_booking->update_status( $status );
                                        $product_id = $item_value->get_product_id();
					bkap_insert_event_to_gcal( $order, $product_id, $item_key );
				}
			}
		}
	}
}
add_action( 'woocommerce_order_status_changed', 'bkap_booking_pending_to_confirmed', 8, 3 );

How can you modify product price with filter bkap_consider_person_settings_without_product_price?

Hook:
bkap_consider_person_settings_without_product_price:

Usage:

add_filter( 'bkap_consider_person_settings_without_product_price', 'bkap_consider_person_settings_without_product_price', 10, 2 );

Parameters: 2

Example:

/**
  * Modify product price with filter when bkap_consider_person_settings_without_product_price.
  * @param bool $total_price - Return total price.
  * @param bool $person_price - Return only person price.
  */
function bkap_consider_person_settings_without_product_price( $total_price, $person_price ) {
	return $person_price;
}
add_filter( 'bkap_consider_person_settings_without_product_price', 'bkap_consider_person_settings_without_product_price', 10, 2 );

How can you not show variations in the Available Bookings Block?

Hook:
bkap_show_variations_in_available_bookings_block:

Usage:

add_filter( 'bkap_show_variations_in_available_bookings_block', '__return_false' );

Parameters: None

Example:

/**
  * Do not show variations in the Available Bookings Block.
  * @return bool false
  */
add_filter( 'bkap_show_variations_in_available_bookings_block', '__return_false' );

How can you consider Booking End date to send the Booking Reminder?

Hook:
bkap_get_past_bookings, bkap_get_future_bookings, bkap_date_compare_for_sending_reminder:

Usage:

add_filter( 'bkap_get_past_bookings', 'bkap_get_past_future_bookings', 10, 1 );

Parameters: 1

add_filter( 'bkap_get_future_bookings', 'bkap_get_past_future_bookings', 10, 1 );

Parameters: 1

add_filter( 'bkap_date_compare_for_sending_reminder', 'bkap_date_compare_for_sending_reminder', 10, 3 );

Parameters: 3

Example:

/**
 * Trigger based on the end date and time.
 */
function bkap_get_past_future_bookings( $args ) {

	$args['meta_key'] = '_bkap_end';

	return $args;
}
add_filter( 'bkap_get_past_bookings', 'bkap_get_past_future_bookings', 10, 1 );
add_filter( 'bkap_get_future_bookings', 'bkap_get_past_future_bookings', 10, 1 );

/**
 * Change comparision date to end date.
 */
function bkap_date_compare_for_sending_reminder( $date, $booking, $reminder ) {

	$date = date( 'Y-m-d H', strtotime( $booking->get_end() ) );

	return $date;
}
add_filter( 'bkap_date_compare_for_sending_reminder', 'bkap_date_compare_for_sending_reminder', 10, 3 );

How can you reschedule Multiple days booking order with initial booking is blocked?

Hook:
bkap_initial_booking_is_locked:

Usage:

add_filter( 'bkap_initial_booking_is_locked', 'bkap_initial_booking_is_locked', 99, 1 );

Parameters: 1

Example:

 /**
  * Multiple days booking reschedule order with initial booking is bolcked.
  * @param bool $init_islocked default value false.
  */
function bkap_initial_booking_is_locked( $init_islocked ) {
	return true;
}
add_filter( 'bkap_initial_booking_is_locked', 'bkap_initial_booking_is_locked', 99, 1 );

How can I set the different colors to different events in Calendar View?

Hook:
bkap_calendar_view_events_data:

Usage:

add_filter( 'bkap_calendar_view_events_data', 'bkap_calendar_data', 10, 1 );

Parameters: 1

Example:

 /**
 * Adding different colors to calendar events based on the product id.
 */
function bkap_calendar_data( $data ) {

	$new_data = array();

	$product_color = array(
		'4701' => 'purple', // here you can add some other combination of product and color
	);

	foreach ( $data as $key => $value ) {

		if ( isset( $product_color[ $value['value']['post_id'] ] ) ) {
			$value['color'] = $product_color[ $value['value']['post_id'] ];
		}

		$new_data[ $key ] = $value;
	}

	return $new_data;
}
add_filter( 'bkap_calendar_view_events_data', 'bkap_calendar_data', 10, 1 );

How can I export only single page data?

Hook:
bkap_export_single_page:

Usage:

add_filter( 'bkap_export_single_page', 'bkap_export_single_page', 99, 1 );

Parameters: 1

Example:

 /**
  * Export only single page data.
  * @param bool $is_single default value false.
  */
function bkap_export_single_page( $is_single ) {
	return true;
}
add_filter( 'bkap_export_single_page', 'bkap_export_single_page', 99, 1 );

How can I set event color according to product and status of booking in Calendar View?

Hook:
bkap_calendar_view_events_data:

Usage:

add_filter( 'bkap_calendar_view_events_data', 'bkap_calendar_data', 10, 1 );

Parameters: 1

Example:

 /**
 * Adding different colors to calendar events based on the product id.
 */
function bkap_calendar_data( $data ) {

	$new_data = array();

	$product_color = array(
		'4810' => array(
			'confirmed'            => 'green',
			'paid'                 => 'white',
			'pending-confirmation' => 'yellow',
			'cancelled'            => 'red',
		), // here you can add some other combination of product and color
		'4999' => array(
			'confirmed'            => 'orange',
			'paid'                 => 'pink',
			'pending-confirmation' => 'gray',
			'cancelled'            => 'red',
		), // here you can add some other combination of product and color
	);

	foreach ( $data as $key => $value ) {

		if ( isset( $product_color[ $value['value']['post_id'] ] ) ) {
			$status         = $value['value']['booking_status']; // get booking status.
			$value['color'] = $product_color[ $value['value']['post_id'] ][ $status ]; // get color according to product and status.
		}

		$new_data[ $key ] = $value;
	}

	return $new_data;
}
add_filter( 'bkap_calendar_view_events_data', 'bkap_calendar_data', 10, 1 );

Hook:
bkap_additional_data_value_in_calendar_tip:

Usage:

add_filter( 'bkap_additional_data_value_in_calendar_tip', 'bkap_additional_data_value_in_calendar_tip', 10, 2 );

Parameters: 1

Example:

 function bkap_additional_data_value_in_calendar_tip( $value, $booking ) {

	$value['booking_id']     = $booking->get_id();
	$value['booking_status'] = $booking->get_status( true );

	return $value;
}
add_filter( 'bkap_additional_data_value_in_calendar_tip', 'bkap_additional_data_value_in_calendar_tip', 10, 2 );

How can I show the selected Fixed Block Information in Order Item Meta?

Hook:
bkap_update_item_meta:

Usage:

add_action( 'bkap_update_item_meta', 'bkap_add_fixed_block_item_data', 10, 3 );

Parameters: 3

Example:

 function bkap_add_fixed_block_item_data( $item_id, $product_id, $booking_data ) {

	if ( isset( $booking_data['fixed_block'] ) && '' !== $booking_data['fixed_block'] ) {

		$booking_settings = bkap_setting( $product_id );

		if ( isset( $booking_settings['booking_fixed_block_enable'] )
			&& $booking_settings['booking_fixed_block_enable'] == 'booking_fixed_block_enable'
			&& $booking_settings['bkap_fixed_blocks_data']
			&& ! empty( $booking_settings['bkap_fixed_blocks_data'] )
		) {

			$selected_fixed_block_data = explode( '&', $booking_data['fixed_block'] );
			$fixed_block_data          = '';
			foreach ( $booking_settings['bkap_fixed_blocks_data'] as $key => $value ) {
				if ( $value['start_day'] == $selected_fixed_block_data[0]
					&& $value['number_of_days'] == $selected_fixed_block_data[1]
					&& $value['price'] == $selected_fixed_block_data[2]
				) {
					$fixed_block_data = $value['block_name'];
				}
			}

			if ( '' != $fixed_block_data ) {
				$fixed_block = __( 'Fixed Block', 'woocommerce-booking' );
				wc_add_order_item_meta( $item_id, $fixed_block, $fixed_block_data );
			}
		}
	}
}
add_action( 'bkap_update_item_meta', 'bkap_add_fixed_block_item_data', 10, 3 );

How can I remove No. of Days and Price per day from Cart & Checkout Page?

Hook:
bkap_get_item_data:

Usage:

add_filter( 'bkap_get_item_data', 'bkap_get_item_data_callback', 10, 2 );

Parameters: 2

Example:

 /**
 * Remove No. of Days and Price per day from Cart and Checkout page.
 * 
 * @param array $other_data Array of Other data.
 * @param array $cart_item Array value of Cart Item.
 */
function bkap_get_item_data_callback( $other_data, $cart_item ) {

	foreach ($other_data as $key => $value) {
		if ( __( 'No. of Days', 'woocommerce-booking' ) == $value['name'] ) {
			unset( $other_data[$key] );
		}

		if ( __( 'Per Day Price', 'woocommerce-booking' ) == $value['name'] ) {
			unset( $other_data[$key] );
		}
	}
	return $other_data;
}
add_filter( 'bkap_get_item_data', 'bkap_get_item_data_callback', 10, 2 );

How can I change the No. of Days and Price per Day string on the Cart & Checkout Page?

Hook:
bkap_get_item_data:

Usage:

add_filter( 'bkap_get_item_data', 'bkap_get_item_data_callback', 10, 2 );

Parameters: 2

Example:

 function bkap_get_item_data_callback( $other_data, $cart_item ) {

	$new_data = $other_data;

	foreach ($other_data as $key => $value) {
		if ( __( 'No. of Days', 'woocommerce-booking' ) == $value['name'] ) {
			$new_data[$key]['name'] = __( 'Days', 'woocommerce-booking' );
		}

		if ( __( 'Per Day Price', 'woocommerce-booking' ) == $value['name'] ) {
			$new_data[$key]['name'] = __( 'Price', 'woocommerce-booking' );
		}
	}
	return $new_data;
}
add_filter( 'bkap_get_item_data', 'bkap_get_item_data_callback', 10, 2 );

How can I show only ten products even is all products are selected in the available bookings block settings?

Hook:
bkap_available_bookings_block_number_posts:

Usage:

add_filter( 'bkap_available_bookings_block_number_posts', 'bkap_available_bookings_block_number_posts_callback', 10, 1 );

Parameters: 1

Example:

 function bkap_available_bookings_block_number_posts_callback() {
	return 10;
}
add_filter( 'bkap_available_bookings_block_number_posts', 'bkap_available_bookings_block_number_posts_callback', 10, 1 );

How can we add an option to set custom timeslots range to show the events in booking calendar in the week and dayvise view?

Hook:
bkap_calendar_timeslot_params:

Usage:

add_filter( 'bkap_calendar_timeslot_params', 'bkap_calendar_timeslot_params_callback', 99, 2 );

Parameters: 2

Example:

 /**
 * Add am option to set custom timeslots to show the events in booking calendar view.
 *
 * @param string $start_time string default value 00:00.
 * @param string $end_time string default value 24:00.
 */
function bkap_calendar_timeslot_params_callback( $start_time, $end_time ) {
	$start_time = '09:00';
	$end_time   = '18:00';

	return array( $start_time, $end_time );
}
add_filter( 'bkap_calendar_timeslot_params', 'bkap_calendar_timeslot_params_callback', 99, 2 );

How can we set the latest product price in Admin while editing the booking?

Hook:
bkap_apply_new_price_on_edit_booking:

Usage:

add_filter( 'bkap_apply_new_price_on_edit_booking', 'bkap_apply_new_price_on_edit_booking_callback', 99, 1 );

Parameters: 1

Example:

 /**
 * Admin edit booking set latest product price.
 *
 * @param bool $is_new boolean default value false.
 */
function bkap_apply_new_price_on_edit_booking_callback( $is_new ) {
	return true;
}
add_filter( 'bkap_apply_new_price_on_edit_booking', 'bkap_apply_new_price_on_edit_booking_callback', 99, 1 );

How can we add the order meta for the booking data?

Hook:
woocommerce_checkout_update_order_meta:

Usage:

add_action( 'woocommerce_checkout_update_order_meta', 'bkap_update_item_meta', 10, 1 );

Parameters: 1

Example:

 /**
 * Adding the order meta for the booking data.
 */
function bkap_update_item_meta( $order_id ) {

	$order       = wc_get_order( $order_id );
	$order_items = $order->get_items();

	foreach ( $order_items as $k => $v ) {

		if ( isset( $v['wapbk_booking_date'] ) && $v['wapbk_checkout_date'] ) {

			// Start Date.
			$date_booking    = bkap_date_as_format( $v['wapbk_booking_date'], 'm-d-Y' );
			$new_bookingdate = date_format( date_create_from_format( 'm-d-Y', $date_booking ), 'Ymd' );
			update_post_meta( $order_id, 'start_date_dont_edit', $new_bookingdate );

			// End Date.
			$date_booking_1   = bkap_date_as_format( $v['wapbk_checkout_date'], 'm-d-Y' );
			$new_bookingdate1 = date_format( date_create_from_format( 'm-d-Y', $date_booking_1 ), 'Ymd' );
			update_post_meta( $order_id, 'end_date_dont_edit', $new_bookingdate1 );

			// (Ship By) Date.
			$date_booking_2   = bkap_date_as_format( $v['wapbk_checkout_date'], 'm-d-Y' );
			$date_booking_new = date( 'Ymd', strtotime( $new_bookingdate . ' - 11 days' ) );
			update_post_meta( $order_id, 'ship_by_date_dont_edit', $date_booking_new );
		}
	}
}
add_action( 'woocommerce_checkout_update_order_meta', 'bkap_update_item_meta', 10, 1 );

How can I show Categories in the Search Widget according to the Menu Order?

Hook:
bkap_category_args_in_widget:

Usage:

add_filter( 'bkap_category_args_in_widget', 'bkap_change_category_args', 10, 1 );

Parameters: 1

Example:

 /* Show Categories in the Search Widget according to the Menu Order */
function bkap_change_category_args( $args ) {

	$args['orderby'] = 'menu_order';

	return $args;
}
add_filter( 'bkap_category_args_in_widget', 'bkap_change_category_args', 10, 1 );

How can we remove uncategorised category from category list in the Availability Search widget?

Hook:
bkap_all_categories_in_widget:

Usage:

add_filter( 'bkap_all_categories_in_widget', 'bkap_remove_uncategorised_category', 10, 1 );

Parameters: 1

Example:

 /**
 * Remove uncategorised category from category list in search widget
 */
function bkap_remove_uncategorised_category( $categories ) {

	$uncategorized_category = get_term_by('name', 'uncategorised', 'product_cat' );

	if ( $uncategorized_category ) {
		$id = $uncategorized_category->term_id;
		if ( isset( $categories[ $id ] ) ) {
			unset( $categories[ $id ] );
		}
	}

	return $categories;
}
add_filter( 'bkap_all_categories_in_widget', 'bkap_remove_uncategorised_category', 10, 1 );

How can I change the CDN path to custom path?

Hook:
bkap_change_cdn_path:

Usage:

add_filter( 'bkap_change_cdn_path', 'bkap_change_cdn_path', 10, 5 );

Parameters: 5

Example:

 /** 
 * we can add https://prnt.sc/cW3AQqpBSM50 filter to file class-bkap-scripts.php file in bkap_asset_url function.
 * and give cdn filder zip to client and ask them to put it to main folder.
 */
function bkap_change_cdn_path( $cdn, $path, $plugin, $use_cdn, $do_minification ) {
	if ( $use_cdn ) {
		$cdn = plugins_url() . '/woocommerce-booking/cdn';
	}

	return $cdn;
}
add_filter( 'bkap_change_cdn_path', 'bkap_change_cdn_path', 10, 5 );

How to disable dates based on the current day?

Hook:
bkap_init_parameter_localize_script_additional_data:

Usage:

add_filter( 'bkap_init_parameter_localize_script_additional_data', 'bkap_init_parameter_localize_script_additional_data_callback', 10, 1 );

Parameters: 1

Example:

 function bkap_init_parameter_localize_script_additional_data_callback( $data ) {
    $today = date( 'w' );
	
    if ( in_array( $today, array( 5, 6, 0 ) )  ) { // if its Friday, Saturday or Sunday then show Tuesday.
		
		if ( isset( $data['fixed_ranges'] ) && '' !== $data['fixed_ranges'] ) {
			$dates        = bkap_common::bkap_get_betweendays( date( 'j-n-Y' ), date( 'j-n-Y', strtotime( 'next Tuesday' ) ), 'j-n-Y' );
			$booked_dates = implode( '","', $dates );
			if ( isset( $data['holidays'] ) && '' !== $data['holidays'] ) {
				$data['holidays'] = $data['holidays'] . ',"' . $booked_dates . '"';
			} else {
				$data['holidays'] = '"' . $booked_dates . '"';
			}

		} else {
			$data['default_date'] = date( 'j-n-Y', strtotime( 'next Tuesday' ) );
		}
	}
    return $data;
}
add_filter( 'bkap_init_parameter_localize_script_additional_data', 'bkap_init_parameter_localize_script_additional_data_callback', 10, 1 );

How can I change the initial view of the Calendar view to something else?

Hook:
bkap_multidates_selection_msg:

Usage:

add_filter( 'bkap_multidates_selection_msg', 'bkap_multidates_message_change', 10, 3 );

Parameters: 1

Example:

function bkap_multidates_message_change( $total_stock_message, $product_id, $booking_settings ) {

	if ( isset( $booking_settings['booking_enable_multiple_day'] ) && 'multidates' === $booking_settings['booking_enable_multiple_day'] ) {
		$multidates_type        = $booking_settings['multidates_type'];
		$multidates_fixed_dates = $booking_settings['multidates_fixed_number'];
		$fixed_multidates_msg   = __( 'Please select FIXED dates to book this product.', 'woocommerce-booking' );
		$total_stock_message    = str_replace(
			array(
				'FIXED',
			),
			array(
				$multidates_fixed_dates,
			),
			$fixed_multidates_msg
		);
	}
	return $total_stock_message;
}
add_filter( 'bkap_multidates_selection_msg', 'bkap_multidates_message_change', 10, 3 );

How can we calculate the price based on the weekdays saturday/sunday – multiple nights booking type?

Hook:
bkap_price_ofsingleday_on_weekend:

Usage:

add_filter( "bkap_price_ofsingleday_on_weekend", "bkap_price_ofsingleday_on_weekend_callback", 10, 7 );

Parameters: 7

Example:

function bkap_price_ofsingleday_on_weekend_callback ( $product_id, $checkin_date, $checkout_date, $number, $product_type, $variation_id, $variations_selected ) {

    $number = 0;
    $bkap_weekdays = bkap_common::bkap_get_betweendays( $checkin_date, $checkout_date );
	$falldays = 0;
	$weekarr = array( "6", "0" );
	
	$bkap_start_weekday = Date( 'w', strtotime( $checkin_date ) );
	$bkap_end_weekday 	= Date( 'w', strtotime($checkout_date ) );

    if ( is_array( $bkap_weekdays ) && count( $bkap_weekdays ) > 0 ) {

        foreach( $bkap_weekdays as $key => $value ){
            $bkap_weekday_pos = Date( 'w', strtotime( $value ) );

            if ( !in_array( $bkap_weekday_pos, $weekarr ) ) {
                $number++;
            } else {
				$falldays++;
			}
        }
	}
    if ( $bkap_start_weekday == 5 && $bkap_end_weekday == 1 ) {
		$_product 		= wc_get_product( $product_id );
		$product_price 	= $_product->get_price();
		$qty 			= $_POST['quantity'];
		$price 			= $product_price . "-fixed" /* * $falldays * $qty */;
    } else {
        $price = bkap_block_booking::price_range_calculate_price( $product_id, $product_type, $variation_id, $number, $variations_selected );
	}

    return $price;
}
add_filter( "bkap_price_ofsingleday_on_weekend", "bkap_price_ofsingleday_on_weekend_callback", 10, 7 );

Hook:
bkap_number_ofselected_days_on_weekend:

Usage:

add_filter("bkap_number_ofselected_days_on_weekend", "bkap_number_ofselected_days_on_weekend_callback", 10, 3);

Parameters: 1

Example:

function bkap_number_ofselected_days_on_weekend_callback ($number, $checkin_date, $checkout_date ) {

    $bkap_weekdays = bkap_common::bkap_get_betweendays( $checkin_date, $checkout_date );

    $weekarr = array( "6", "0" );

    if ( is_array( $bkap_weekdays ) && count( $bkap_weekdays ) > 0 ) {
        $number = 0;

        foreach( $bkap_weekdays as $key => $value ){
            $bkap_weekday_pos = Date( 'w', strtotime( $value ) );

            if ( !in_array( $bkap_weekday_pos, $weekarr ) ) {
                $number++;
            }
        }
    }

    return $number;
}
add_filter("bkap_number_ofselected_days_on_weekend", "bkap_number_ofselected_days_on_weekend_callback", 10, 3);

Hook:
bkap_modify_booking_price:

Usage:

add_filter( "bkap_modify_booking_price", "bkap_modify_booking_price_callback", 10, 1 );

Parameters: 1

Example:

/**
 * Add saturday price only if selected as beginning date
 */
add_filter( "bkap_modify_booking_price", "bkap_modify_booking_price_callback", 10, 1 );
function bkap_modify_booking_price_callback( $price ){
	$checkin_date = $_POST['checkin_date'];
	$day          = date( 'w', strtotime( $checkin_date ) );
	if ( '6' === $day || '0' === $day ) {
		$product_id    = $_POST['post_id'];
		$_product      = wc_get_product( $product_id );
		$product_price = $_product->get_price();
		$qty           = $_POST['quantity'];
		$price         = $price + ( $product_price * $qty );
	}
	return $price;
}

How can we show the notice below booking form based on the selected number of days on the mentioned seasons week in the code?

Hook:
bkap_validating_booking_with_high_season:

Usage:

add_action( 'bkap_validating_booking_with_high_season', 'bkap_validating_booking_with_high_season_callback', 10, 6 );

Parameters: 6

Example:

/* Hook to validate the shortbreaks based on the high/low seasons */

function bkap_validating_booking_with_high_season_callback( $product_id, $product_type, $variation_id, $checkin_date, $checkout_date, $currency_selected ) {

    $do_not_allow_blocks = array(   "912"   => "3,4", // Key is product id and value is block days which are shortbreaks - Skylands Cottage
                                    "905"   => "2,3", // Key is product id and value is block days which are shortbreaks - Rose cottage Reeth
                                    "4230"  => "2,3",
                                    "39"    => "2,3"  // Key is product id and value is block days which are shortbreaks - The little Barn
                                );

    $diff_days = $_POST['diff_days'];

    $current_date   = date( "Y-m-d" );
    $year           = date( 'Y', strtotime( $checkin_date ) );
    $week_number    = date( 'W', strtotime( $checkin_date ) );
    $current_week   = date( 'W' );

    /* Listing all the high seasons */
    $high_season    = array(    "2019" => "01,02,04,06,07,08,09,10,11,12,13,14,15,16,17,18,45,46,47,48",
                                "2020" => "01,03,05,07,08,45,45,47",
                                "2021" => "03,04,05,06,11,12,13,14,33,34,45,46"
                        );

    print( 'jQuery( "#show_time_slot" ).html("");'); // removing the message if it is previously displayd for any selection

    if ( strpos( $high_season[ $year ], $week_number ) !== false ) {

        if ( isset( $do_not_allow_blocks[ $product_id ] ) && strpos( $do_not_allow_blocks[ $product_id ], $diff_days ) !== false ) {
            
            if ( ( $week_number - $current_week ) < 4 ) {

                $error_message = __( "This is a high season date and short breaks can only be booked 4 weeks in advance of the requested date.", "woocommerce-booking" );
                
                print( 'jQuery( "#show_time_slot" ).show();');
                print( 'jQuery( "#show_time_slot" ).html( "

' . addslashes( $error_message ) . '

");'); print( 'jQuery( "html, body" ).animate({ scrollTop: ( jQuery( "#show_time_slot" ).offset().top - 100 )}, 1000 );' ); // change 5000 die(); } } } } add_action( 'bkap_validating_booking_with_high_season', 'bkap_validating_booking_with_high_season_callback', 10, 6 );

How can we remove the Booking details from WooCommerce Emails?

Hook:
woocommerce_order_item_get_formatted_meta_data:

Usage:

add_filter( 'woocommerce_order_item_get_formatted_meta_data', 'unset_booking_order_item_meta_data', 10, 2 );

Parameters: 2

Example:

/**
 * Removing Booking details from WooCommerce Emails.
 */
function unset_booking_order_item_meta_data( $formatted_meta, $item ) {

	$start_date = bkap_option( 'email_start_date' );
	$end_date   = bkap_option( 'email_end_date' );
	$time       = bkap_option( 'email_time' );

	if ( did_action( 'woocommerce_email_order_meta' ) || did_action( 'woocommerce_email_before_order_table' ) ) {
		foreach ( $formatted_meta as $key => $meta ) {
			if ( in_array( $meta->key, array( $start_date, $end_date, $time ), true ) ) {
				unset( $formatted_meta[ $key ] );
			}
		}
	}
}
add_filter( 'woocommerce_order_item_get_formatted_meta_data', 'unset_booking_order_item_meta_data', 10, 2 );

How can we add the Additional Comment textarea on Create Booking form?

Hook:
bkap_after_manual_booking_created:

Usage:

add_filter( 'bkap_initial_booking_is_locked', 'bkap_initial_booking_is_locked', 99, 1 );

Parameters: 1

Example:

/**
 * Adding textarea after booking form when creating manual booking.
 */
function bkap_additional_fields() {
	echo '
'; echo ''; echo ''; echo '
'; } add_action( 'bkap_after_booking_form_on_create_booking', 'bkap_additional_fields', 11 ); /** * Saving textarea value as order item upon successful creation of manual booking. * * @param array $status Array of data regarding created booking. */ function bkap_add_additional_details_to_order_item_meta( $status ) { if ( isset( $status['item_id'] ) && '0' != $status['item_id'] && isset( $_POST['bkap_additional_comment'] ) && '' !== $_POST['bkap_additional_comment'] ) { $item_id = $status['item_id']; wc_add_order_item_meta( $item_id, 'Additional Comment', $_POST['bkap_additional_comment'] ); } return $status; } add_action( 'bkap_after_manual_booking_created', 'bkap_add_additional_details_to_order_item_meta', 10, 1 );

How can I avoid to apply the tax on deposits amount?

Hook:
woocommerce_before_calculate_totals:

Usage:

add_action( 'woocommerce_before_calculate_totals', 'bkap_do_not_apply_tax_on_deposits', 10, 1 );

Parameters: 1

Example:

/**
 * Do not apply the tax on the deposits amount. 
 */
function bkap_do_not_apply_tax_on_deposits( $cart ) {
	foreach ( $cart->get_cart() as $cart_item_key => $cart_item ) {

		if ( isset( $cart_item['bkap_booking'] ) ) {

			if ( isset( $cart_item['bkap_booking'][0]['default_Deposit'] ) && 0 != $cart_item['bkap_booking'][0]['default_Deposit'] ) {
				$cart_item['data']->set_tax_class( 'zero-rate' ); // Ensure 'zero-rate' matches your 0% tax class slug.
			}
		}
	}
}
add_action( 'woocommerce_before_calculate_totals', 'bkap_do_not_apply_tax_on_deposits', 10, 1 );

How to show the remaining amount information in the Payment Status Column?

Hook:
bkap_view_booking_individual_data:

Usage:

add_filter( 'bkap_view_booking_individual_data', 'bkap_view_booking_individual_data_deposits', 10, 3 );

Parameters: 3

Example:

/**
 * Show remaining amount info in the Payment Status Column. 
 */
function bkap_view_booking_individual_data_deposits( $booking_data, $booking, $booking_id ) {

	if ( $booking_data['payment_status'] === __( 'Partially Paid', 'woocommerce-booking' ) || $booking_data['payment_status'] === __( 'Awaiting Balance Payment', 'woocommerce-booking' ) ) {
		$order_item_id = $booking->custom_fields['_bkap_order_item_id'][0];
		if ( isset( $order_item_id ) ) {
			$child_order_id = wc_get_order_item_meta( $order_item_id, '_bkap_remaining_balance_order_id' );
			if ( isset( $child_order_id ) && '' !== $child_order_id && false !== $child_order_id ) {
				$child_order = wc_get_order( $child_order_id );
				if ( 'pending' === $child_order->get_status() ) {
					$deposit_remaining              = wc_get_order_item_meta( $order_item_id, '_bkap_remaining' );
					$booking_data['payment_status'] = $booking_data['payment_status'] . ' - ' . wc_price( $deposit_remaining );

				}
			} else {
				$product_id        = $booking->product_id;
				$booking_settings  = get_post_meta( $product_id, 'woocommerce_booking_settings', true );
				$deposit_remaining = wc_get_order_item_meta( $order_item_id, '_bkap_remaining' );

				if ( isset( $booking_settings['booking_partial_payment_radio'] ) && 'security_deposit' !== $booking_settings['booking_partial_payment_radio'] ) {

					if ( isset( $deposit_remaining ) && $deposit_remaining != 0 && '' != $deposit_remaining ) { // phpcs:ignore
						$booking_data['payment_status'] = $booking_data['payment_status'] . ' - ' . wc_price( $deposit_remaining );
					}
				}
			}
		}
	}

	return $booking_data;
}
add_filter( 'bkap_view_booking_individual_data', 'bkap_view_booking_individual_data_deposits', 10, 3 );

How can we show the notice above the booking form on the front end of the product page?

Hook:
wp_footer:

Usage:

add_action( 'wp_footer', 'bkap_move_woocommerce_notices_above_booking_form' );

Parameters: 1

Example:

 /**
 * Function to enqueue the custom script to move WooCommerce Error Notices
 */
function bkap_move_woocommerce_notices_above_booking_form() {
    if ( is_product() ) {
        ?>
        
        

How can we change the duration of the notice on product page?

Hook:
bkap_time_for_error_notice_to_be_displayed:

Usage:

add_filter( 'bkap_time_for_error_notice_to_be_displayed', 'bkap_custom_notice_time', 10, 1 );

Parameters: 1

Example:

 /**
 * To always show the notice or to change the duration of the notice being removed from the product page.
 * Default time is 5 secs.
 */
function bkap_custom_notice_time( $time ) {
    return 0;
}
add_filter( 'bkap_time_for_error_notice_to_be_displayed', 'bkap_custom_notice_time', 10, 1 );

What code I can use to not consider the disabled weekdays in the number of days selected?

Hook:
bkap_selected_number_of_nights:

Usage:

add_filter( 'bkap_selected_number_of_nights', 'bkap_selected_number_of_nights', 10, 5 );

Parameters: 5

Example:

 function bkap_selected_number_of_nights( $number, $checkin_date, $checkout_date, $product_id, $booking_settings ) {

	$dates    = bkap_common::bkap_get_betweendays( $checkin_date, $checkout_date, 'Y-m-d' );
	foreach ( $dates as $date ) {
		$day          = date( 'w', strtotime( $date ) );
		$weekday_name = 'booking_weekday_' . $day;

		if ( '' === $booking_settings['booking_recurring'][$weekday_name] ) {
			$number = $number - 1;
		}
	}
	$number = bkap_selected_number_of_nights_seasonal( $number, $checkin_date, $checkout_date, $product_id, $booking_settings );
	return $number;
}
add_filter( 'bkap_selected_number_of_nights', 'bkap_selected_number_of_nights', 10, 5 );

Hook:
bkap_consider_date_for_season:

Usage:

add_filter( 'bkap_consider_date_for_season', 'bkap_consider_date_for_season', 10, 4 );

Parameters: 4

Example:

 function bkap_consider_date_for_season( $consider, $date_value, $product_id, $booking_settings ) {

	$day          = gmdate( 'w', strtotime( $date_value ) );
	$weekday_name = 'booking_weekday_' . $day;
	if ( '' === $booking_settings['booking_recurring'][ $weekday_name ] ) {
		return false;
	}
	return $consider;
}
add_filter( 'bkap_consider_date_for_season', 'bkap_consider_date_for_season', 10, 4 );

How can we set the default status to pending confirmation and upon changing the payment to confirmed?

Hook:
bkap_booking_status_on_create_order:

Usage:

add_filter( 'bkap_initial_booking_is_locked', 'bkap_initial_booking_is_locked', 99, 1 );

Parameters: 1

Example:

 /**
 * Change the default booking status to pending confirmation when the order is placed.
 *
 * @param string $status Status of Booking.
 */
function bkap_booking_status_on_create_order( $status ) {
	return 'pending-confirmation';
}
add_filter( 'bkap_booking_status_on_create_order', 'bkap_booking_status_on_create_order', 10, 1 );

Hook:
woocommerce_order_status_changed:

Usage:

add_action( 'woocommerce_order_status_changed', 'bkap_booking_pending_to_confirmed', 8, 3 );

Parameters: 3

Example:

 function bkap_booking_pending_to_confirmed( $order_id, $old_status, $new_status ) {

	if ( 'failed' !== $old_status && in_array( $new_status, array( 'processing' ), true ) ) {

		$order       = wc_get_order( $order_id );
		$order_items = $order->get_items();
		foreach ( $order_items as $item_key => $item_value ) {
			$booking_status = wc_get_order_item_meta( $item_key, '_wapbk_booking_status' );
			if ( isset( $booking_status ) && 'pending-confirmation' === $booking_status ) {
				$status = 'confirmed';
				wc_update_order_item_meta( $item_key, '_wapbk_booking_status', $status );
				$booking_id = bkap_common::get_booking_id( $item_key );
				if ( $booking_id ) {
					$new_booking = bkap_checkout::get_bkap_booking( $booking_id );
					$new_booking->update_status( $status );
					$product_id = $item_value->get_product_id();
					bkap_insert_event_to_gcal( $order, $product_id, $item_key );
				}
			}
		}
	}
}
add_action( 'woocommerce_order_status_changed', 'bkap_booking_pending_to_confirmed', 8, 3 );

How can we change the booking information that is present in session/cookies?

Hook:
bkap_date_from_session_cookie:

Usage:

add_filter( 'bkap_date_from_session_cookie', 'bkap_date_from_session_cookie', 10, 1 );

Parameters: 1

Example:

 /**
 * This function is used to modify the session date based on the selected date in some custom booking form.
 */
function bkap_date_from_session_cookie( $date ) {
	if ( $date ) {
		if ( str_contains( $date, '/' ) ) {
			$d    = DateTime::createFromFormat( 'j/n/y', $date );
			$date = $d->format( 'Y-m-d' );
		}
	}
	return $date;
}
add_filter( 'bkap_date_from_session_cookie', 'bkap_date_from_session_cookie', 10, 1 );

How can we show the Booking price with tax text?

Hook:
bkap_final_price_json_data:

Usage:

add_filter( 'bkap_final_price_json_data', 'bkap_show_booking_price_with_tax', 10, 2 );

Parameters: 2

Example:

 function bkap_show_booking_price_with_tax( $wp_send_json, $product_id ) {

	if ( 'yes' !== get_option( 'woocommerce_calc_taxes' ) ) {
		return $wp_send_json;
	}

	$product_obj = wc_get_product( $product_id );
	$total_price = $wp_send_json['total_price_calculated'];

	$tax_rates = WC_Tax::get_rates( $product_obj->get_tax_class() );

	if ( wc_prices_include_tax() ) {
		$taxes        = WC_Tax::calc_inclusive_tax( $total_price, $tax_rates );
		$included_tax = array_sum( $taxes );

		if ( $included_tax > 0 ) {
			$display_price  = $wp_send_json['bkap_price'];
			$display_price .= ' (' . sprintf( __( 'includes %s tax', 'woocommerce'), wc_price( $included_tax ) ) . ')';

			$wp_send_json['bkap_price'] = $display_price;
		}
	} else {
		$taxes      = WC_Tax::calc_exclusive_tax( $total_price, $tax_rates );
		$tax_amount = array_sum( $taxes );

		if ( $tax_amount > 0 ) {
			$display_price  = $wp_send_json['bkap_price'];
			$display_price .= ' (' . sprintf( __( 'plus %s tax', 'woocommerce' ), wc_price( $tax_amount ) ) . ')';

			$wp_send_json['bkap_price'] = $display_price;
		}
	}

	return $wp_send_json;
}
add_filter( 'bkap_final_price_json_data', 'bkap_show_booking_price_with_tax', 10, 2 );

How can we change the "Please select time slot..." text?

Hook:
bkap_change_hover_text_for_disabled_dates:

Usage:

add_filter( 'bkap_change_hover_text_for_disabled_dates', 'bkap_change_select_timeslot_message', 10, 1 );

Parameters: 1

Example:

 function bkap_change_select_timeslot_message( $labels ) {

	$labels['time_slot_not_selected'] = __( 'Custom Please select time slot...', 'woocommerce-booking' );

	return $labels;
}
add_filter( 'bkap_change_hover_text_for_disabled_dates', 'bkap_change_select_timeslot_message', 10, 1 );

How can we change Persons text?

Hook:
bkap_persons_label:

Usage:

add_filter( 'bkap_persons_label', 'bkap_persons_label' );

Parameters: 1

Example:

function bkap_persons_label() {

	return __( 'Custom Persons', 'woocommerce-booking' );
}
add_filter( 'bkap_persons_label', 'bkap_persons_label' );

Was this article helpful to you? Yes No

How can we help?