PluginProbe
Booking Calendar / 10.1.3
Booking Calendar v10.1.3
11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 All 203 releases
booking / core / wpbc-dev-api.php

wpbc-dev-api.php in Booking Calendar 10.1.3, at core/wpbc-dev-api.php

654 lines 33.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @version 1.0
4 * @package Booking Calendar
5 * @subpackage Dev API for integration Booking Calendar with third party
6 * @category API
7 *
8 * @author wpdevelop
9 * @link https://wpbookingcalendar.com/
10 * @email info@wpbookingcalendar.com
11 *
12 * @modified 2017-06-24
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
17 //FixIn: 8.0
18
19 // ---------------------------------------------------------------------------------------------------------------------
20 // Add New Booking
21 // ---------------------------------------------------------------------------------------------------------------------
22 /**
23 * Add New Booking
24 *
25 * @param array $booking_dates // array( '2017-06-24', '2017-06-24', '2017-06-25' );
26 * @param array $booking_data // array(
27 * 'secondname' => array( 'value' => 'Rika' , 'type' => 'text' )
28 * , 'name' => 'Jo' // 'text' field type, if in such format
29 * , 'rangetime' => array( 'value' => '14:00 - 16:00', 'type' => 'selectbox-one' )
30 * , 'email' => array( 'value' => 'rika@cost.com', 'type' => 'email' )
31 * )
32 * @param int $resource_id // Optional. Default: 1
33 * @param type $params // Optional. Default: array(
34 * 'is_send_emeils' => 0
35 * , 'booking_form_type' => ''
36 * , 'wpdev_active_locale' => 'en_US'
37 * , 'is_show_payment_form' => 0
38 * , 'is_edit_booking' => false | array( 'booking_id' => 75, 'booking_type' => 1 )
39 * , 'save_booking_even_if_unavailable' => 0 // 0 | 1 - if 1 then save booking without checking if this date available. Usually save to main booking resource
40 * , 'is_use_booking_recurrent_time' => false
41 * )
42 * @return int|WP_Error - booking ID or WP_Error
43 *
44 *
45 ***********************************************************************************************************************
46 * Notes!
47 * If you need to book for specific time, then its have to be in appropriate field(s) at $booking_data - booking form. In $booking_dates times have been sliced.
48 * It does not check about booked | available dates in calendar with capacity > 1 !!!!
49 * If the single booking resource booked for specific dates and settings have activated "Checking to prevent double booking, during submitting booking" then system just DIE
50 ***********************************************************************************************************************
51 *
52 * Examples:
53 *
54 - AddSimple
55 $booking = array(
56 'dates' => array( '2017-06-24', '2017-06-24', '2017-06-25', '2017-06-26' )
57 , 'data' => array(
58 'secondname' => array( 'value' => 'Rika', 'type' => 'text' )
59 , 'name' => 'John'
60 , 'email' => array( 'value' => 'rika@cost.com', 'type' => 'email' )
61 )
62 );
63 $booking_id = wpbc_api_booking_add_new( $booking[ 'dates' ], $booking[ 'data' ] );
64
65 - Resource
66 $booking = array(
67 'dates' => array( '2017-06-24', '2017-06-24', '2017-06-25', '2017-06-26' )
68 , 'data' => array(
69 'secondname' => array( 'value' => 'Rika', 'type' => 'text' )
70 , 'name' => 'JoNNNNNNNNNN'
71 , 'rangetime' => array( 'value' => '14:00 - 16:00', 'type' => 'selectbox-one' )
72 , 'email' => array( 'value' => 'rika@cost.com', 'type' => 'email' )
73 )
74 , 'resource_id' => 3
75
76 );
77 $booking_id = wpbc_api_booking_add_new( $booking[ 'dates' ], $booking[ 'data' ], $booking[ 'resource_id' ] );
78
79
80 - Edit:
81 $booking = array(
82 'dates' => array( '2017-06-24', '2017-06-24', '2017-06-25', '2017-06-28' )
83 , 'data' => array(
84 'secondname' => array( 'value' => 'Rika', 'type' => 'text' )
85 , 'name' => 'BoBy'
86 , 'rangetime' => array( 'value' => '14:00 - 16:00', 'type' => 'selectbox-one' )
87 , 'email' => array( 'value' => 'rika@cost.com', 'type' => 'email' )
88 )
89 , 'resource_id' => 3
90 , 'params' => array( 'is_edit_booking' => array( 'booking_id' => 79, 'booking_type' => 3 ) )
91
92 );
93 $booking_id = wpbc_api_booking_add_new( $booking[ 'dates' ], $booking[ 'data' ], $booking[ 'resource_id' ], $booking[ 'params' ] );
94 *
95 */
96 function wpbc_api_booking_add_new( $booking_dates, $booking_data, $resource_id = 1, $params = array() ) {
97
98 /*
99 // Dates in format: 'Y-m-d'
100 $booking_dates = array( '2017-06-24', '2017-06-24', '2017-06-25' );
101
102 // Booking Form params
103 $booking_data = array(
104 'secondname' => array( 'value' => 'Rika' , 'type' => 'text' )
105 , 'rangetime' => array( 'value' => '14:00 - 16:00', 'type' => 'selectbox-one' )
106 , 'email' => array( 'value' => 'rika@cost.com', 'type' => 'email' )
107 );
108 // Booking resource ID
109 $resource_id = 1;
110 */
111
112 // Other params
113 $defaults = array(
114 'is_send_emeils' => 0
115 , 'booking_form_type' => '' // custom_form_name
116 , 'wpdev_active_locale' => 'en_US' // locale
117 , 'is_show_payment_form' => 0 // Parameters for adding booking in the HTML:
118 , 'is_edit_booking' => false // array( 'booking_id' => 75, 'booking_type' => 1 ) // Update Booking params
119 , 'is_use_booking_recurrent_time' => ( 'On' === get_bk_option( 'booking_recurrent_time' ) )
120 );
121 $params = wp_parse_args( $params, $defaults );
122
123
124 // booking resource ID
125 $resource_id = intval( $resource_id );
126 $resource_id = ( empty( $resource_id ) ? 1 : $resource_id );
127 $params[ 'bktype' ] = $resource_id;
128
129
130 // Dates ///////////////////////////////////////////////////////////////////////////////////////////////////////////
131 $booking_dates = array_map( 'strtotime', $booking_dates ); // Array ( [0] => 1498262400 [1] => 1498348800 )
132 sort( $booking_dates ); // Sort
133 $booking_dates = array_unique( $booking_dates ); // Remove Duplicates
134 $dates_formats = array_fill( 0, count( $booking_dates ), "d.m.Y" ); // Array ( [0] => d.m.Y [1] => d.m.Y )
135 $booking_dates = array_map( 'date_i18n', $dates_formats , $booking_dates ); // Array ( [0] => 24.06.2017 [1] => 25.06.2017 )
136 $booking_dates = implode(', ', $booking_dates); // 24.06.2017, 25.06.2017
137 $params[ 'dates' ] = $booking_dates;
138
139
140 // Booking Form ////////////////////////////////////////////////////////////////////////////////////////////////////
141 $booking_form = array();
142 foreach ( $booking_data as $field_name => $field_params ) {
143
144 if ( is_array( $field_params ) ) {
145
146 $booking_form_field = array( $field_params['type'], $field_name . $resource_id, $field_params['value'] );
147 } else { // value just string
148 $booking_form_field = array( 'text', $field_name . $resource_id, $field_params );
149 }
150 $booking_form_field[ 0 ] = str_replace( array( '^', '~' ), array( 'curret', 'tilde' ), $booking_form_field[ 0 ] ); // replace to temp symbols
151 $booking_form_field[ 1 ] = str_replace( array( '^', '~' ), array( 'curret', 'tilde' ), $booking_form_field[ 1 ] );
152 $booking_form_field[ 2 ] = str_replace( array( '^', '~' ), array( 'curret', 'tilde' ), $booking_form_field[ 2 ] );
153
154 $booking_form_field = implode( '^' , $booking_form_field );
155 $booking_form []= $booking_form_field;
156 }
157 $booking_form = implode( '~' , $booking_form );
158 $params[ 'form' ] = $booking_form;
159
160
161 $resource_id = $params['bktype'];
162
163
164 $booking_hash = '';
165 if ( ! empty( $params['is_edit_booking'] ) ) {
166
167 $hash__arr = wpbc_hash__get_booking_hash__resource_id( $params['is_edit_booking']['booking_id'] ); // Get new booking hash
168
169 if ( ! empty( $hash__arr ) ) {
170 list( $booking_hash, $resource_id ) = $hash__arr;
171 }
172 }
173
174
175 // Create a new booking
176 $request_save_params = array(
177 'resource_id' => $resource_id, // 2
178 'dates_ddmmyy_csv' => $params[ 'dates' ], // '04.10.2023, 05.10.2023, 06.10.2023'
179 'form_data' => $params[ 'form' ], // 'text^cost_hint2^150.00฿~selectbox-multiple^rangetime2[]^14:00...'
180 'booking_hash' => $booking_hash, // 'sdfsf34534rf'
181 'custom_form' => $params['booking_form_type'], // 'custom_form_name'
182 'is_emails_send' => $params['is_send_emeils'], // 0 | 1
183 'is_show_payment_form' => intval( $params['is_show_payment_form'] ), // 0 | 1
184 // 'request_uri' => $_SERVER['HTTP_REFERER']
185 // 'user_id' => wpbc_get_current_user_id()
186 'sync_gid' => ( ( ! empty( $params['sync_gid'] ) ) ? $params['sync_gid'] : '' ),
187 'is_approve_booking' => ( ( ! empty( $params['is_approve_booking'] ) ) ? $params['is_approve_booking'] : 0 ), // Auto approve booking ??
188 'save_booking_even_if_unavailable' => ( ( ! empty( $params['save_booking_even_if_unavailable'] ) ) ? $params['save_booking_even_if_unavailable'] : 0 ), // Force saving booking without checking
189 'is_use_booking_recurrent_time' => intval( $params['is_use_booking_recurrent_time'] )
190 );
191
192 $booking_save_arr = wpbc_booking_save( $request_save_params );
193 if ( 'ok' === $booking_save_arr['ajx_data']['status'] ) { // Everything Cool :) - booking has been duplicated
194 $booking_id = $booking_save_arr['booking_id'];
195 } else { // Error
196 $booking_id = 0;
197 // Error message: $booking_save_arr['ajx_data']['ajx_after_action_message'];
198 return new WP_Error( 'wpbc_api_booking_add_new__error', $booking_save_arr['ajx_data']['ajx_after_action_message'] );
199 }
200
201 return $booking_id;
202 }
203
204 // ---------------------------------------------------------------------------------------------------------------------
205 // Is Date Booked ?
206 // ---------------------------------------------------------------------------------------------------------------------
207 /**
208 * Check if dates available in specific resource
209 *
210 * @param array $booking_dates // [ "2023-09-27 23:30:01","2023-09-28 00:00:00","2023-09-29 00:59:52" ] Range List of Dates in MySQL format, like: array( '2017-06-23 14:00:01', '2017-06-24 00:00:00', '2017-06-25', '2017-06-26 12:00:02' );
211 * @param int $resource_id // 9 Optional. Default: 1
212 * @param array $params // [ 'is_use_booking_recurrent_time' => false ] Optional. Default: array( ) -- For future improvement
213 *
214 * @return bool // true | false
215 *
216 * Examples:
217 *
218 * $booking = array(
219 * 'dates' => array( '2017-06-23 14:00:01', '2017-06-24 00:00:00', '2017-06-25', '2017-06-26 12:00:02' )
220 * , 'resource_id' => 1
221 * , 'params' => array( 'is_use_booking_recurrent_time' => false )
222 * );
223 * $result = wpbc_api_is_dates_booked( $booking[ 'dates' ], $booking[ 'resource_id' ], $booking[ 'params' ] );
224 */
225 function wpbc_api_is_dates_booked( $booking_dates, $resource_id = 1, $params = array() ) {
226
227 $defaults = array(
228 'is_use_booking_recurrent_time' => ( 'On' === get_bk_option( 'booking_recurrent_time' ) )
229 );
230 $params = wp_parse_args( $params, $defaults );
231
232
233 // Convert: ["2023-09-27 23:30:01","2023-09-28 00:00:00","2023-09-29 00:59:52"] -> [ "2023-10-18", "2023-10-25", "2023-11-25" ]
234 $dates_only_sql_arr = array_map( function ( $value ) {
235 $value_arr = explode( ' ', $value );
236 return $value_arr[0];
237 }, $booking_dates );
238
239 // Convert: ["2023-09-27 23:30:01","2023-09-28 00:00:00","2023-09-29 00:59:52"] -> [ 36000, 39600 ]
240 $time_as_seconds_arr = array( $booking_dates[0], $booking_dates[ ( count( $booking_dates ) - 1 ) ], );
241 $time_as_seconds_arr = array_map( function ( $value ) {
242 $value_arr = explode( ' ', $value );
243 $time_sec = wpbc_transform__24_hours_his__in__seconds( $value_arr[1] );
244 return $time_sec;
245 }, $time_as_seconds_arr );
246
247
248 /**
249 * Get slots [] where we can save booking = [ 'resources_in_dates' => [ 2023-10-18 = [ 2, 12, 10, 11 ]
250 * 2023-10-19 = [ 2, 12, 10, 11 ]
251 * 2023-10-20 = [ 2, 12, 10, 11 ]
252 * ],
253 * 'time_to_book' => [ "14:00:01" , "12:00:01" ],
254 * 'result' => 'ok'
255 * 'main__resource_id' => 2
256 * ]
257 * OR
258 * [ 'result' => 'error', 'message' => 'Booking can not be saved ...' ]
259 */
260 $where_to_save_booking = wpbc__where_to_save_booking( array(
261 'resource_id' => $resource_id, // 2
262 'skip_booking_id' => '', // '', | 125 if edit booking
263 'dates_only_sql_arr' => $dates_only_sql_arr, // [ "2023-10-18", "2023-10-25", "2023-11-25" ]
264 'time_as_seconds_arr' => $time_as_seconds_arr, // [ 36000, 39600 ]
265 'how_many_items_to_book' => 1, // 1
266 'request_uri' => ( ( ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ) ? $_SERVER['HTTP_REFERER'] : $_SERVER['REQUEST_URI'] ), // front-end: $_SERVER['REQUEST_URI'] | ajax: $_SERVER['HTTP_REFERER'] // It different in Ajax requests. It's used for change-over days to detect for exception at specific pages, // 'http://beta/resource-id2/'
267 'as_single_resource' => true, // false
268 'is_use_booking_recurrent_time' => $params['is_use_booking_recurrent_time']
269 ) );
270
271 if ( 'ok' != $where_to_save_booking['result'] ) {
272 $is_dates_times_unavailable = true;
273 /**
274 *
275 $ajx_data_arr['status'] = 'error';
276 $ajx_data_arr['status_error'] = 'booking_can_not_save';
277 $ajx_data_arr['ajx_after_action_message'] = $where_to_save_booking['message'];
278 $ajx_data_arr['ajx_after_action_message_status'] = 'warning';
279 return array( 'ajx_data' => $ajx_data_arr );
280 */
281 } else {
282 $is_dates_times_unavailable = false;
283 }
284
285 return $is_dates_times_unavailable;
286 }
287
288 // ---------------------------------------------------------------------------------------------------------------------
289 // Get Bookings Array - [Listing]
290 // ---------------------------------------------------------------------------------------------------------------------
291 /**
292 * Get bookings array from Booking Calendar
293 *
294 * @param aray $params
295 * @return array
296 ( [bookings] => Array (
297 [2661] => stdClass Object (
298 [booking_id] => 2661
299 [trash] => 0
300 [sync_gid] => 5t3ogfsb3tqj09po7fiou6hh60@google.com
301 [is_new] => 1
302 [status] =>
303 [sort_date] => 2017-08-07 20:00:01
304 [modification_date] => 2017-07-08 11:54:03
305 [form] => text^name4^Event (timezone Pacific GMT-07:00)~....
306 [hash] => 69afc11e2ce86044dd55fbddf582ce66
307 [booking_type] => 4
308 [remark] =>
309 [cost] => 51.98
310 [pay_status] => 149950764311
311 [pay_request] => 0
312 [dates] => Array (
313 [0] => stdClass Object (
314 [booking_id] => 2661
315 [booking_date] => 2017-08-07 20:00:01
316 [approved] => 0
317 [type_id] => )
318 [1] => stdClass Object (
319 [booking_id] => 2661
320 [booking_date] => 2017-08-08 00:00:00
321 [approved] => 0
322 [type_id] =>
323 )
324 )
325 [dates_short] => Array (
326 [0] => 2017-08-07 20:00:01
327 [1] => -
328 [2] => 2017-08-08 00:00:00 )
329 [form_show] => 'First Name: John....'
330 [form_data] => Array (
331 [email] => ics@beta
332 [name] => Event (timezone Pacific GMT-07:00)
333 [secondname] =>
334 [visitors] => 1
335 [coupon] =>
336 [_all_] => Array (
337 [name4] => Event (timezone Pacific GMT-07:00)
338 [details4] => 8/7/2017 1:00pm TO 3:30pm 8/8/2017 (GMT-07:00) Pacific Time
339 [email4] => ics@beta
340 [rangetime4] => 20:00 - 00:00
341 [sync_gid4] => 5t3ogfsb3tqj09po7fiou6hh60@google.com
342 )
343 [_all_fields_] => Array (
344 [name] => Event (timezone Pacific GMT-07:00)
345 [details] => 8/7/2017 1:00pm TO 3:30pm 8/8/2017 (GMT-07:00) Pacific Time
346 [email] => ics@beta
347 [rangetime] => 20:00 - 00:00
348 [sync_gid] => 5t3ogfsb3tqj09po7fiou6hh60@google.com
349 [booking_resource_id] => 4
350 [resource_id] => 4
351 [type_id] => 4
352 [type] => 4
353 [resource] => 4
354 [booking_id] => 2661
355 [resource_title] => stdClass Object (
356 [booking_type_id] => 4
357 [title] => Apartment#3
358 [users] => 1
359 [import] => some_email@group.calendar.google.com
360 [cost] => 25.99
361 [default_form] => standard
362 [prioritet] => 40
363 [parent] => 0
364 [visitors] => 1
365 [id] => 4
366 [count] => 1
367 [ID] => 4
368 )
369 )
370 [rangetime] => 20:00 - 00:00
371 )
372 [dates_short_id] => Array (
373 [0] =>
374 [1] =>
375 [2] =>
376 )
377 )
378 ....
379 )
380 [resources] => Array (
381 [4] => stdClass Object
382 (
383 [booking_type_id] => 4
384 [title] => Apartment#3
385 [users] => 1
386 [import] => some_email@group.calendar.google.com
387 [cost] => 25.99
388 [default_form] => standard
389 [prioritet] => 40
390 [parent] => 0
391 [visitors] => 1
392 [id] => 4
393 [count] => 1
394 [ID] => 4
395 )
396 ....
397 )
398 [bookings_count] => 2
399 [page_num] => 1
400 [count_per_page] => 100000
401 )
402 *
403 */
404 function wpbc_api_get_bookings_arr( $params = array() ) {
405
406 // Start Date of getting bookings
407 $real_date = strtotime( 'now' );
408 $wh_booking_date = date_i18n( "Y-m-d", $real_date ); // '2012-12-01';
409
410 // End date of getting bookings
411 $real_date = strtotime( '+1 year' );
412 $wh_booking_date2 = date_i18n( "Y-m-d", $real_date ); // '2013-02-31';
413
414 // params
415 $defaults = array(
416 'wh_booking_type' => '1'
417 , 'wh_approved' => ''
418 , 'wh_booking_id' => ''
419 , 'wh_is_new' => ''
420 , 'wh_pay_status' => 'all'
421 , 'wh_keyword' => ''
422 , 'wh_booking_date' => $wh_booking_date
423 , 'wh_booking_date2' => $wh_booking_date2
424 , 'wh_modification_date' => '3'
425 , 'wh_modification_date2' => ''
426 , 'wh_cost' => ''
427 , 'wh_cost2' => ''
428 , 'or_sort' => ''
429 , 'page_num' => '1'
430 , 'wh_trash' => '' // '' | trash | any //FixIn: 8.0.2.8
431 , 'limit_hours' => '0,24'
432 , 'only_booked_resources' => 0
433 , 'page_items_count' => '100000'
434 );
435 $params = wp_parse_args( $params, $defaults );
436
437 $bookings_arr = wpbc_get_bookings_objects( $params );
438
439 return $bookings_arr;
440 }
441
442 //FixIn: 8.7.6.4
443 /**
444 * Get Booking Data as array of properties
445 *
446 * @param string $booking_id - digit '11' or comma separated '11,19,12'
447 *
448 * @return array
449 */
450 function wpbc_api_get_booking_by_id( $booking_id = '' ) {
451
452 global $wpdb;
453 $booking_id = wpbc_clean_digit_or_csd( $booking_id );
454
455 $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";
456 $slct_sql = $wpdb->prepare( $slct_sql, $booking_id );
457 $slct_sql_results = $wpdb->get_results( $slct_sql, ARRAY_A );
458
459 $data = array();
460
461 if ( count( $slct_sql_results ) > 0 ) {
462 $data = $slct_sql_results[0];
463 $formdata_array = explode( '~', $data['form'] );
464
465 $formdata_array_count = count( $formdata_array );
466 for ( $i = 0; $i < $formdata_array_count; $i ++ ) {
467
468 if ( empty( $formdata_array[ $i ] ) ) {
469 continue;
470 }
471 $elemnts = explode( '^', $formdata_array[ $i ] );
472 $type = $elemnts[0];
473 $element_name = $elemnts[1];
474 $value = $elemnts[2];
475 $value = nl2br( $value );
476 $data['formdata'][ $element_name ] = $value;
477 }
478 }
479 return $data;
480 }
481
482 //FixIn: 8.7.7.3
483 /**
484 * Get booking form fields in Booking Calendar Free version
485 * @return array
486 */
487 function wpbc_get_form_fields_free() {
488 $obj = array();
489 if ( class_exists( 'WPBC_Page_SettingsFormFieldsFree' ) ) {
490
491 //FixIn: 8.7.8.7
492 $form_free = new WPBC_Page_SettingsFormFieldsFree();
493 $form_fields = $form_free->get_booking_form_structure_for_visual();
494 foreach ( $form_fields as $field ) {
495 //FixIn: 8.7.8.7
496 if ( ( ! empty( $field['name'] ) )
497 && ( ! empty( $field['label'] ) )
498 && ( ! in_array( $field['type'], array(
499 'captcha',
500 'submit'
501 ) ) )
502 ) {
503 $obj[ $field['name'] ] = $field['label'];
504 }
505 }
506 }
507 return $obj;
508 }
509
510
511 /**
512 * DEPRECATED :: Hook action after creation new booking
513 * @param int $booking_id
514 * @param int $resource_id
515 * @param string $str_dates__dd_mm_yyyy - "30.02.2014, 31.02.2014, 01.03.2014"
516 * @param array $times_array - array($start_time, $end_time )
517 * @param string $booking_form
518 function your_cust_func_add_new_booking( $booking_id, $resource_id, $str_dates__dd_mm_yyyy, $times_array , $booking_form ) {
519
520 }
521 add_action( 'show_payment_forms__for_ajax', 'your_cust_func_add_new_booking', 100, 5 );
522 *
523 Previously: add_action( 'wpdev _new_booking', 'your_cust_func_add_new_booking', 100, 5 );
524 */
525
526 /**
527 * NEW :: Hook action after creation / edit bookings
528 *
529 * How to use this hook?
530 *
531 * Add code similar to this in your functions.php file in your theme, or in some other php file:
532 *
533 * // Track adding new booking
534 * //
535 * // @param $params = array (
536 * 'str_dates__dd_mm_yyyy' => '08.10.2023,09.10.2023,10.10.2023,11.10.2023',
537 * 'booking_id' => 254,
538 * 'resource_id' => 11, // child or parent or single
539 * 'initial_resource_id' => 2, // parent or single
540 * 'form_data' => 'text^selected_short_dates_hint11^Sun...',
541 * 'times_array' => array ( array ( '14', '00', '01' ), array( '12', '00', '02' ) ),
542 * 'is_edit_booking' => 0,
543 * 'custom_form' => '',
544 * 'is_duplicate_booking' => 0,
545 * 'is_from_admin_panel' => false,
546 * 'is_show_payment_form' => 1
547 * )
548 * function my_booking_tracking( $params ){
549 * // Your code here
550 * ?><!-- Google Code for Booking Conversion Page -->
551 * <script type="text/javascript">
552 * // Insert bellow your Google Conversion Code
553 * </script><?php
554 * }
555 * add_action( 'wpbc_track_new_booking', 'my_booking_tracking' );
556 *
557 *
558 *
559 * Useful hook booking edit tracking
560 *
561 * Add code similar to this in your functions.php file in your theme, or in some other php file:
562 *
563 * // Track edit existing booking
564 * //
565 * // @param $params = array (
566 * 'str_dates__dd_mm_yyyy' => '08.10.2023,09.10.2023,10.10.2023,11.10.2023',
567 * 'booking_id' => 254,
568 * 'resource_id' => 11, // child or parent or single
569 * 'initial_resource_id' => 2, // parent or single
570 * 'form_data' => 'text^selected_short_dates_hint11^Sun...',
571 * 'times_array' => array ( array ( '14', '00', '01' ), array( '12', '00', '02' ) ),
572 * 'is_edit_booking' => 1,
573 * 'custom_form' => '',
574 * 'is_duplicate_booking' => 0,
575 * 'is_from_admin_panel' => false,
576 * 'is_show_payment_form' => 1
577 * )
578 * function my_edit_booking_tracking( $params ){
579 * // Your code here
580 * ?><!-- Google Code for Booking Conversion Page -->
581 * <script type="text/javascript">
582 * // Insert bellow your Google Conversion Code
583 * </script><?php
584 * }
585 * add_action( 'wpbc_track_edit_booking', 'my_edit_booking_tracking' );
586 */
587
588 /**
589 * Hook action after approving of booking: do_action( 'wpbc_booking_approved' , $booking_id , $is_approved_dates );
590 * @param int/string $booking_id - can be '1' or 99 or comma separated ID of bookings: '10,22,45'
591 * @param int/string $is_approved_dates - '1' | '0' | 1 | 0 1 -approved, 0 - pending
592 function your_cust_func_wpbc_booking_approved( $booking_id, $is_approved_dates ) {
593
594 }
595 add_action( 'wpbc_booking_approved', 'your_cust_func_wpbc_booking_approved', 100, 2 ); //FixIn: 8.7.6.1
596 */
597
598 /**
599 * Hook action after trash of booking:
600 * do_action( 'wpbc_booking_trash', $booking_id, $is_trash ); //FixIn: 8.7.6.2
601 */
602
603 /**
604 * Hook action after delete of booking:
605 * do_action( 'wpbc_booking_delete', $approved_id_str ); //FixIn: 8.7.6.3
606 */
607
608 /**
609 * Hooks in new Booking Listing page for different actions:
610 * //FixIn: 9.5.3.3
611 do_action( 'wpbc_set_booking_locale', $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
612 do_action( 'wpbc_set_booking_pending', $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
613 do_action( 'wpbc_set_booking_approved' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
614 do_action( 'wpbc_move_booking_to_trash' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
615 do_action( 'wpbc_restore_booking_from_trash' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
616 do_action( 'wpbc_delete_booking_completely' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
617 do_action( 'wpbc_set_booking_as_read' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
618 do_action( 'wpbc_set_booking_as_unread' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
619
620 do_action( 'wpbc_set_booking_note' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
621 do_action( 'wpbc_change_booking_resource' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
622
623 do_action( 'wpbc_set_payment_status' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
624 do_action( 'wpbc_set_booking_cost' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
625 do_action( 'wpbc_send_payment_request' $params, $action_result ); // where $params is array, which contain $params['booking_id'], and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
626 do_action( 'wpbc_import_google_calendar' $params, $action_result ); // where $params is array and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
627 do_action( 'wpbc_export_csv' $params, $action_result ); // where $params is array and $action_result array and have $action_result['after_action_result'], which contains a boolean value of the result of an operation.
628
629 */
630
631 /**
632 * Hook for adding new payment status(es) in Booking Listing page:
633 *
634 * apply_filters ('wpbc_filter_payment_status_list' , $payment_status_titles );
635 *
636 * Use this code in your functions.php file in your theme to add your own Payment status for Booking Listing page:
637 *
638 * function my_wpbc_filter_payment_status_list( $payment_status_titles ) {
639 * $payment_status_titles[ 'invoice' ] = ' Invoice Payment';
640 * return $payment_status_titles;
641 * }
642 * add_filter( 'wpbc_filter_payment_status_list', 'my_wpbc_filter_payment_status_list', 10, 1 );
643 */
644
645 /**
646 * Hook that executes upon the deletion of booking resources: do_action( 'wpbc_deleted_booking_resources', $bulk_action_arr_id ); // (10.0.0.35)
647 *
648 * Example:
649 * function my_func__on_resource_delete( $resources_id_str ){
650 * $resources_id_arr = explode( ',', $resources_id_str );
651 * // Do something ...
652 * }
653 * add_action( 'wpbc_deleted_booking_resources', 'my_func__on_resource_delete' );
654 */