Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    Please check some info about this here https://wpbookingcalendar.com/faq/booking-calendar-api/
    Kind Regards.

    Thread Starter manicozyvision

    (@manicozyvision)

    Hi,

    Thank you for your reply. I checked the given file link. But it does not fulfil my purpose. I want to capture the events such as new booking , booking approved, booking denied, booking pending, booking deleted. For your reference, I am sharing below file links and line number where updation is required. Please look into these files and revert back to me as soon as possible.

    booking\core\lib\wpbc-ajax.php
    line 195
    line 199
    line 255
    line 405

    booking\core\lib\wpbc-booking-new.php
    line 450
    line 508
    line 563

    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    We will add hooks in a future updates of Booking Calendar similar to this, for all those lines:

    
    do_action( 'wpbc_booking_approved' , $booking_id , $is_approved_dates ); //FixIn: 8.7.6.1
    

    or

    
    do_action( 'wpbc_booking_trash', $booking_id, $is_trash ); //(8.7.6.2)
    

    or

    
    do_action( 'wpbc_booking_delete', $approved_id_str ); //(8.7.6.3)
    

    Kind Regards.

    Thank you.

    This will really help us.

    I would request you to add only one common hook for all events, that has all the information, like

    all booking meta data, including status, that gets triggerred at different events.

    For eg. booking created, status changed, etc.

    If you want we can contribute to this piece of code, as few of our customers are willing to have it live soon, you can review and merge it to your code.

    Thanks

    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    Please share it, to check more detail, what exactly you are mean.
    Kind Regards.

    Thread Starter manicozyvision

    (@manicozyvision)

    Please add below hooks at the below files
    booking\core\lib\wpbc-ajax.php
    line 199
    line 204
    line 259
    line 410

    booking\core\lib\wpbc-booking-new.php
    line 187
    line 451
    line 509
    line 565

    add this function to booking\core\wpbc-dev-api.php line 17 to 45
    function wpbc_api_get_booking_by_id($booking_id=null)
    {
    global $wpdb;
    $slct_sql = “SELECT * FROM {$wpdb->prefix}booking as b left join {$wpdb->prefix}bookingdates as bd on (b.booking_id = bd.booking_id) WHERE b.booking_id IN ({$booking_id}) LIMIT 0,1”;
    $slct_sql_results = $wpdb->get_results( $slct_sql,ARRAY_A );
    if ( count($slct_sql_results) > 0 ) {
    $data = $slct_sql_results[0];
    $formdata_array = explode(‘~’,$data[‘form’]);

    $formdata_array_count = count($formdata_array);
    for ( $i=0 ; $i < $formdata_array_count ; $i++) {

    if ( empty( $formdata_array[$i] ) ) {
    continue;
    }
    $elemnts = explode(‘^’,$formdata_array[$i]);
    $type = $elemnts[0];
    $element_name = $elemnts[1];
    $value = $elemnts[2];
    $value = nl2br($value);
    $data[‘formdata’][$element_name] = $value;
    }

    }

    return $data;

    }

    I have made above changes to 3 files, you can download from below link to check and merge in your code

    https://projects.cozyvision.com/booking.zip

    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    I will add this function:

    
    
    /**
     * Get Booking Data as array of properties
     * 
     * @param string $booking_id  - digit '11' or comma separated '11,19,12' 
     *
     * @return array
     */
    function wpbc_api_get_booking_by_id( $booking_id = '' ) {
    	
    	global $wpdb;
    	$booking_id = wpbc_clean_digit_or_csd( $booking_id );
    
    	$slct_sql         = "SELECT * FROM {$wpdb->prefix}booking as b left join {$wpdb->prefix}bookingdates as bd on (b.booking_id = bd.booking_id) WHERE b.booking_id IN (%s) LIMIT 0,1";
    	$slct_sql         = $wpdb->prepare( $slct_sql, $booking_id );
    	$slct_sql_results = $wpdb->get_results( $slct_sql, ARRAY_A );
    	
    	$data = array();
    	
    	if ( count( $slct_sql_results ) > 0 ) {
    		$data           = $slct_sql_results[0];
    		$formdata_array = explode( '~', $data['form'] );
    
    		$formdata_array_count = count( $formdata_array );
    		for ( $i = 0; $i < $formdata_array_count; $i ++ ) {
    
    			if ( empty( $formdata_array[ $i ] ) ) {
    				continue;
    			}
    			$elemnts                           = explode( '^', $formdata_array[ $i ] );
    			$type                              = $elemnts[0];
    			$element_name                      = $elemnts[1];
    			$value                             = $elemnts[2];
    			$value                             = nl2br( $value );
    			$data['formdata'][ $element_name ] = $value;
    		}
    	}
    	return $data;
    }

    Kind Regards.

    Thread Starter manicozyvision

    (@manicozyvision)

    waiting for the update of the plugin. Please revert.

    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    Its will be available in next update 8.7.6
    Currently you can simply add that function into the php file (../booking/core/wpbc-dev-api.php).
    I can not say about the exact date of update release. Sorry.
    Kind Regards.

    Thread Starter manicozyvision

    (@manicozyvision)

    Thank you for updating the hooks in your last release of your plugin.
    We need your assistance for below points:

    1. We found that we need a function to retrieve the form fields. So we request you to add the below function in wpbc-dev-api.php

    function getFormFields()
    {
    	$obj=array();
    	if(class_exists('WPBC_Page_SettingsFormFieldsFree'))
    	{
    		$form_fields = WPBC_Page_SettingsFormFieldsFree::get_booking_form_structure_for_visual();
    		foreach($form_fields as $field)
    		{
    			if($field['name'] != '' && $field['label'] != '' &&  !in_array($field['type'],array('captcha','submit')))
    			{
    				$obj[$field['name']]=$field['label'];
    			}
    		}
    	}
    	return $obj;
    }

    2. We have smsalert plugin so we require phone field in booking form. we do not want users to add the phone field manually.You have already done it for email field i.e is automated created by plugin and non-removable. Please suggest a solution for it.

    Hope positive response from your side. Thanks in advance.

    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    1) I will add this function to that file:

    
    //FixIn: 8.7.7.3
    /**
     * Get booking form  fields in Booking Calendar Free version
     * @return array
     */
    function wpbc_get_form_fields_free() {
    	$obj = array();
    	if ( class_exists( 'WPBC_Page_SettingsFormFieldsFree' ) ) {
    		$form_fields = WPBC_Page_SettingsFormFieldsFree::get_booking_form_structure_for_visual();
    		foreach ( $form_fields as $field ) {
    			if (    ( $field['name'] != '' )
    			     && ( $field['label'] != '' ) 
    		         && ( ! in_array( $field['type'], array(
    														'captcha',
    														'submit'
    													) ) )
    	        ) {
    				$obj[ $field['name'] ] = $field['label'];
    			}
    		}
    	}
    	return $obj;
    }
    

    2) Unfortunately, we can not set the “phone” field as required field for the booking form. Some customers, sometimes need even Email field to set as not required, so setting phone field as required will make confusing for many customers.
    Thank you for understanding.

    Kind Regards.

    Hi,

    For point 2 can we have any of the below solutions.

    Option 1: you can provide us the API/function to create phone field, and our plugin will create a phone field to his form, this way user does not have to do much configuration.

    Option 2: You can create a default phone field, which can not be deleted, but user can disable/enable it from your plugin, this way name for phone field will never change.

    Or Any other solution you may propose.

    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    We will add this feature to the TODO list for having it in future updates of plugin, but I can not say, when this feature will be implemented. Sorry.
    Kind Regards.

    Hi Team,

    Thanks for the updated plugin.

    There are few more suggestions, which would help us complete our integration.

    1. In line 444 – booking\core\wpbc-dev-api.php

    please replace $field['name'] != '' to !empty($field['name']) as its throwing error when name key does not exists

    2. In line 428 – booking\core\admin\page-form-free.php

    please make the function static, as when we are calling function wpbc_get_form_fields_free it throws error “Deprecated: Non-static method WPBC_Page_SettingsFormFieldsFree::get_booking_form_structure_for_visual() should not be called statically”

    • This reply was modified 4 years, 4 months ago by Cozy Vision.
    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    I will replace content of that function in this file booking\core\wpbc-dev-api.php
    to this content:

    
    function wpbc_get_form_fields_free() {
    	$obj = array();
    	if ( class_exists( 'WPBC_Page_SettingsFormFieldsFree' ) ) {
    		
    		//FixIn: 8.7.8.7
    		$form_free = new WPBC_Page_SettingsFormFieldsFree();
    		$form_fields = $form_free->get_booking_form_structure_for_visual();
    		foreach ( $form_fields as $field ) {
    			//FixIn: 8.7.8.7
    			if (    ( ! empty( $field['name'] ) )
    			     && ( ! empty( $field['label'] ) )
    		         && ( ! in_array( $field['type'], array(
    														'captcha',
    														'submit'
    													) ) )
    	        ) {
    				$obj[ $field['name'] ] = $field['label'];
    			}
    		}
    	}
    	return $obj;
    }

    Kind Regards.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Hook needed’ is closed to new replies.