Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Docs Home

Packages

  • BKAP
    • Addons
    • Admin-Bookings
    • Attribute-Lockout
    • Block-Pricing
    • Booking-Box
    • Booking-Confirmation
    • Booking-Process
    • Cancel-Order
    • Cart
    • Checkout-Process
    • Core
    • Date-Time
    • Emails
    • Functions
    • Global-Function
    • Global-Settings
    • Google-Calendar-Sync
    • ICS
    • Import-Booking
    • Labels
    • License
    • Menus
    • Meta-Boxes
    • Reschedule
    • Resources
    • Search-Widget
    • Special-Price
    • Uninstall
    • Validation
    • Variation-Lockout
    • Vendors
      • Dokan
      • WC-Vendors
    • View-Bookings
  • None

Classes

  • bkap_addon_compatibility_class
  • bkap_admin_bookings
  • bkap_approve_booking
  • bkap_attributes
  • bkap_block_booking
  • BKAP_Booking
  • bkap_booking_box_class
  • bkap_booking_confirmation
  • bkap_booking_process
  • BKAP_Bookings_View
  • bkap_calendar_sync
  • bkap_cancel_order
  • bkap_cart
  • bkap_checkout
  • bkap_common
  • BKAP_Customer_Meta_Box
  • BKAP_Details_Meta_Box
  • bkap_dokan_calendar_class
  • bkap_dokan_class
  • bkap_dokan_orders_class
  • bkap_dokan_products_class
  • bkap_edit_bookings_class
  • BKAP_Email_Booking_Cancelled
  • BKAP_Email_Booking_Confirmed
  • BKAP_Email_Booking_Rescheduled_Admin
  • BKAP_Email_Imported_Event
  • BKAP_Email_Manager
  • BKAP_Email_New_Booking
  • BKAP_Gcal
  • BKAP_Gcal_Event
  • bkap_gcal_sync_settings
  • bkap_global_settings
  • BKAP_Google_Events_View
  • bkap_ics
  • bkap_license
  • bkap_load_scripts_class
  • BKAP_OPC_Addon
  • BKAP_Payment_Gateway
  • BKAP_Product_Resource
  • bkap_rescheduled_order_class
  • BKAP_Resource_Details_Meta_Box
  • BKAP_Save_Meta_Box
  • bkap_special_booking_price
  • bkap_timeslot_price
  • bkap_validation
  • bkap_variations
  • BKAP_Vendors
  • bkap_wc_vendors
  • bkap_wcv_product
  • Booking_Information_In_Voucher_Template
  • Class_Bkap_Product_Resource
  • Custom_WooCommerce_Widget_Product_Search
  • EDD_BOOK_Plugin_Updater
  • global_menu
  • import_bookings
  • product_gcal_settings
  • view_bookings
  • WAPBK_Import_Bookings_Table
  • WAPBK_View_Bookings_Table
  • woocommerce_booking

Functions

  • addDayswithdate
  • bkap_400_create_meta
  • bkap_400_recurring_data
  • bkap_400_update_db_tab
  • bkap_400_update_enable_specific
  • bkap_400_update_enable_week_blocking
  • bkap_400_update_holidays
  • bkap_400_update_ranges
  • bkap_400_update_recurring_lockout
  • bkap_400_update_settings
  • bkap_400_update_special
  • bkap_400_update_specific
  • bkap_410_create_meta
  • bkap_410_update_block_pricing_option_values_in_new_way
  • bkap_410_update_fixed_blocks
  • bkap_410_update_price_ranges
  • bkap_410_update_settings
  • bkap_420_add_gcal_posts
  • bkap_420_add_gcal_tour_posts
  • bkap_420_gcal_batch_size
  • bkap_420_gcal_meta
  • bkap_420_update_settings
  • bkap_add_days_to_date
  • bkap_array_of_given_date_range
  • bkap_booked_resources
  • bkap_booking_posts_for_resource
  • bkap_calculate_bookings_for_resource
  • bkap_check_booking_available
  • bkap_check_day_booking_available
  • bkap_check_for_max_date
  • bkap_check_for_min_date
  • bkap_check_holiday
  • bkap_check_in_custom_holiday_range
  • bkap_check_resource_available
  • bkap_check_resource_booked_in_date_range
  • bkap_db_420_1
  • bkap_db_420_2
  • bkap_delete_event_from_gcal
  • bkap_delete_folder_and_files
  • bkap_delete_options
  • bkap_delete_tables
  • bkap_find_matching_product_variation
  • bkap_generate_bookable_data
  • bkap_get_book_arrays
  • bkap_get_book_t
  • bkap_get_booked
  • bkap_get_booked_checkout
  • bkap_get_custom_posts
  • bkap_get_dateToCal
  • bkap_get_day_between_Week
  • bkap_get_db_count
  • bkap_get_escapeString
  • bkap_get_lockout
  • bkap_get_month_range
  • bkap_get_post_meta
  • bkap_get_posted_availability
  • bkap_get_total_timeslot_maximum_booking
  • bkap_get_week_range
  • bkap_import_events_cron
  • bkap_insert_event_to_gcal
  • bkap_manual_db_update_v420
  • bkap_orderby_date_key
  • bkap_save_resources
  • bkap_sort_by_from_time
  • bkap_update_po_file
  • bkap_vendors_get_bookings
  • bkap_widgets_init
  • bkapSortByPriority
  • calback_bkap_max_date
  • check_in_fixed_block_booking
  • check_in_range
  • check_in_range_abp
  • check_in_range_holidays
  • check_in_range_weekdays
  • create_posts
  • get_availability_for_date
  • get_booked_multiple
  • get_bookings_for_date
  • get_bookings_for_range
  • get_date_lockout
  • get_slot_availability
  • get_slot_lockout
  • get_standard_decimal_thousand_separator_price
  • is_booking_active
  • woocommerce_bkap_add_cron_schedule
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 
<?php 
/**
 * Bookings and Appointment Plugin for WooCommerce
 *
 * Class for booking posts, this handles all the data
 *
 * @author   Tyche Softwares
 * @package  BKAP/Core
 * @category Classes
 * @class    BKAP_Booking
 */

class BKAP_Booking {

    /** @public int */
    public $id;

    /** @public string */
    public $booking_date;

    /** @public string */
    public $start;

    /** @public string */
    public $end;

    /** @public bool */
    public $all_day;

    /** @public string */
    public $modified_date;

    /** @public object */
    public $post;

    /** @public int */
    public $product_id;

    /** @public object */
    public $product;

    /** @public int */
    public $order_id;

    /** @public object */
    public $order;

    /** @public int */
    public $customer_id;

    /** @public string */
    public $status;

    /** @public string */
    public $gcal_event_uid;
    
    /** @public array - contains all post meta values for this booking */
    public $custom_fields;

    /** @public bool */
    public $populated;

    /** @private array - used to temporarily hold order data for new bookings */
    private $order_data;

    /**
     * Constructor, possibly sets up with post or id belonging to existing booking
     * or supplied with an array to construct a new booking
     * 
     * @param int/array/obj $booking_data
     * @since 4.1.0
     */
    public function __construct( $booking_data = false ) {
        $populated = false;

        if ( is_array( $booking_data ) ) {
            $this->order_data = $booking_data;
            $populated = false;
        } else if ( is_object( $booking_data ) && isset( $booking_data->ID ) ) {
            $this->post = $booking_data;
            $populated = $this->populate_data( $booking_data->ID );
        } else if ( is_int( intval( $booking_data ) ) && 0 < $booking_data ) {
            $populated = $this->populate_data( $booking_data );
        }

        $this->populated = $populated;
    }
    
    /**
     * Populate the data with the id of the booking provided.
     * Will query for the post belonging to this booking and store it
     * 
     * @param integer $booking_id - Booking Post ID
     * @return boolean True for success, else False
     * 
     * @since 4.1.0
     */
    public function populate_data( $booking_id ) {
        if ( ! isset( $this->post ) ) {
            $post = get_post( $booking_id );
        }else {
            $post = $this->post;
        }
    
        if ( is_object( $post ) ) {
            // We have the post object belonging to this booking, now let's populate
            $this->id            = $post->ID;
            $this->booking_date  = $post->post_date;
            $this->modified_date = $post->post_modified;
            $this->customer_id   = $post->post_author;
            $this->custom_fields = get_post_meta( $this->id );
            $this->status        = $post->post_status;
            $this->order_id      = $post->post_parent;
    
            // Define the data we're going to load: Key => Default value
            $load_data = array(
                'product_id'  => '',
                'qty'         => 1,
                'resource_id' => '',
                'persons'     => array(),
                'cost'        => '',
                'start'       => '',
                'customer_id' => '',
                'end'         => '',
                'all_day'     => 0,
                'parent_id'   => 0,
                'variation_id'=> 0,
                'gcal_event_uid' => false,
            );
    
            // Load the data from the custom fields (with prefix for this plugin)
            $meta_prefix = '_bkap_';
    
            foreach ( $load_data as $key => $default ) {
                if ( isset( $this->custom_fields[ $meta_prefix . $key ][0] ) && $this->custom_fields[ $meta_prefix . $key ][0] !== '' ) {
                    $this->$key = maybe_unserialize( $this->custom_fields[ $meta_prefix . $key ][0] );
                } else {
                    $this->$key = $default;
                }
            }
    
            // Start and end date converted to timestamp
            $this->start = strtotime( $this->start );
            $this->end   = strtotime( $this->end );
    
            // Save the post object itself for future reference
            $this->post = $post;
            return true;
        }
    
        return false;
    }
    
    /**
    * Create new booking post for the order.
    * 
    * @param string - Status for new booking post
    * @since 4.1.0
    */
    public function create( $status = 'confirmed' ) {
        $this->new_booking( $status, $this->order_data );
    }
    
    /**
     * Create Booking post
     
     * @param string $status - The status for this new booking
     * @param array $order_data - Array with all the new booking data
     * @since 4.1.0
     */
    private function new_booking( $status, $order_data ) {
        global $wpdb;
    
        $order_data = wp_parse_args( $order_data, array(
            'user_id'           => 0,
            'resource_id'       => '',
            'product_id'        => '',
            'order_item_id'     => '',
            'persons'           => array(),
            'cost'              => '',
            'start_date'        => '',
            'end_date'          => '',
            'all_day'           => 0,
            'parent_id'         => 0,
            'qty'               => 1,
            'variation_id'      => 0,
            'gcal_event_uid'    => false,
        ) );
    
        $order_id = $order_data[ 'parent_id' ];
        
        $booking_data = array(
            'post_type'   => 'bkap_booking',
            'post_title'  => sprintf( __( 'Booking &ndash; %s', 'woocommerce-booking' ), strftime( _x( '%b %d, %Y @ %I:%M %p', 'Booking date parsed by strftime', 'woocommerce-booking' ) ) ),
            'post_status' => $status,
            'ping_status' => 'closed',
            'post_parent' => $order_id
        );
    
        $this->id = wp_insert_post( $booking_data );
    
        // Setup the required data for the current user
        if ( ! $order_data['user_id'] ) {
            if ( is_user_logged_in() ) {
                $order_data['user_id'] = get_current_user_id();
            } else {
                $order_data['user_id'] = 0;
            }
        }
    
       $meta_args = array(
            '_bkap_order_item_id' => $order_data['order_item_id'],
            '_bkap_product_id'    => $order_data['product_id'],
            '_bkap_resource_id'   => $order_data['resource_id'],
            '_bkap_persons'       => $order_data['persons'],
            '_bkap_cost'          => $order_data['cost'],
            '_bkap_start'         => $order_data['start_date'],
            '_bkap_end'           => $order_data['end_date'],
            '_bkap_all_day'       => intval( $order_data['all_day'] ),
            '_bkap_parent_id'     => $order_data['parent_id'],
            '_bkap_customer_id'   => $order_data['user_id'],
            '_bkap_qty'           => $order_data[ 'qty' ],
            '_bkap_variation_id'  => $order_data[ 'variation_id' ],
            '_bkap_gcal_event_uid'=> $order_data[ 'gcal_event_uid' ],
        );

        foreach ( $meta_args as $key => $value ) {
            update_post_meta( $this->id, $key, $value );
        }
    
        do_action( 'bkap_new_booking', $this->id );
    }
    
    /**
     * Returns the id of this booking
     * 
     * @return Id of the booking or false if booking is not populated
     * @since 4.1.0
     */
    public function get_id() {
        if ( $this->populated ) {
            return $this->id;
        }
    
        return false;
    }
    
    /**
     * Returns the status of this booking
     * 
     * @param Bool to ask for pretty status name (if false)
     * @return String of the booking status
     * @since 4.1.0
     */
    public function get_status( $raw = true ) {
        if ( $this->populated ) {
        if ( $raw ) {
                return $this->status;
            } else {
                $status_object = get_post_status_object( $this->status );
                return $status_object->label;
            }
        }
    
        return false;
    }
    
    /**
     * Set the new status for this booking
     * @param string $status - New Status
     * @return boolean - True for success, else False
     * @since 4.1.0
     */
    public function update_status( $status ) {
        $current_status   = $this->get_status( true );
        $allowed_statuses = bkap_common::get_bkap_booking_statuses();
        
        if ( $this->populated ) {
            
            if ( array_key_exists( $status, $allowed_statuses ) ) {
                
                wp_update_post( array( 'ID' => $this->id, 'post_status' => $status ) );

                // Trigger actions
                do_action( 'bkap_post_' . $current_status . '_to_' . $status, $this->id );
                do_action( 'bkap_post_' . $status, $this->id );
    
                // Note in the order
                if ( $order = $this->get_order() ) {
                    $order->add_order_note( sprintf( __( 'Booking #%d status changed from "%s" to "%s"', 'woocommerce-booking' ), $this->id, $current_status, $status ) );
                }
    
                return true;
            }
        }
    
        return false;
    }
    
    /**
     * Returns the object of the order corresponding to this booking
     * 
     * @return Order object or false if booking is not populated
     * @since 4.1.0
     */
    public function get_order() {
        if ( empty( $this->order ) ) {
            if ( $this->populated && ! empty( $this->order_id ) && 'shop_order' === get_post_type( $this->order_id ) ) {
                $this->order = wc_get_order( $this->order_id );
            } else {
                return false;
            }
        }
    
        return $this->order;
    }
    

    /**
     * Returns the Customer ID
     * 
     * @return integer Customer ID
     * @since 4.1.0
     */
    public function get_customer_id() {
    
        if ( ! empty( $this->customer_id ) ) {
            return $this->customer_id;
        } else {
            return false;
        }
    }
    
    /**
     * Returns the Order ID
     * 
     * @return integer Order ID
     * @since 4.1.0
     */
    public function get_order_id() {
    
        if ( empty( $this->order_id ) ) {
            if ( ! empty( $this->order ) ) {
                $order_id = $this->order->get_id();
                return $order_id;
            }
        } else {
            return $this->order_id;
        }
    }

    /**
     * Returns the Product ID
     * 
     * @return Product ID
     * @since 4.1.0
     */
    public function get_product_id() {
         
        if ( empty( $this->product_id ) ) {
            if ( ! empty( $this->product ) ) {
                return $this->product->id;
            }
        } else {
            return $this->product_id;
        }
    }
    
    /**
     * Returns the Product Object
     * 
     * @return Product Object
     * @since 4.1.0
     */
    public function get_product() {
         
        if ( empty( $this->product ) ) {
            if ( ! empty( $this->product_id ) ) {
                return wc_get_product( $this->product_id );
            }
        } else {
            return $this->product;
        }
    }
    
    /**
     * Returns the Order Date
     * 
     * @return Order Date
     * @since 4.1.0
     */
    public function get_date_created() {
         
        if ( ! empty( $this->order_id ) ) {
            $order_post = get_post( $this->order_id );
            if ( $order_post ) {
                $post_date = strtotime ( $order_post->post_date );
                $order_date = date( 'Y-m-d H:i:s', $post_date );
            }else {
                $order_date = __( 'Order date not available', 'woocommerce-booking' );
            }

            return $order_date;
        }
    }
    
    /**
     * Returns the Customer Object
     * 
     * @return Customer Object
     * @since 4.1.0
     */
    public function get_customer() {
        $name    = '';
        $email   = '';
        $user_id = 0;
    
        if ( $order = $this->get_order() ) {
            $first_name = is_callable( array( $order, 'get_billing_first_name' ) ) ? $order->get_billing_first_name() : $order->billing_first_name;
            $last_name  = is_callable( array( $order, 'get_billing_last_name' ) ) ? $order->get_billing_last_name()   : $order->billing_last_name;
            $name       = trim( $first_name . ' ' . $last_name );
            $email      = is_callable( array( $order, 'get_billing_email' ) ) ? $order->get_billing_email()           : $order->billing_email;
            $user_id    = is_callable( array( $order, 'get_customer_id' ) ) ? $order->get_customer_id()               : $order->customer_user;
            $name       = 0 !== absint( $user_id ) ? $name : sprintf( _x( '%s (Guest)', 'Guest string with name from booking order in brackets', 'woocommerce-bookings' ), $name );
        } elseif ( $this->get_customer_id() ) {
            $user    = get_user_by( 'id', $this->get_customer_id() );
            $name    = $user->display_name;
            $email   = $user->user_email;
            $user_id = $this->get_customer_id();
        }
        return (object) array(
            'name'    => $name,
            'email'   => $email,
            'user_id' => $user_id,
        );
    }
    
    /**
     * Returns the Start Date
     * 
     * @return Start Date as YmdHis
     * @since 4.1.0
     */
    function get_start() {
        return $start = get_post_meta( $this->id, '_bkap_start', true );
    }
    
    /**
     * Returns the End Date
     * 
     * @return End Date as YmdHis
     * @since 4.1.0
     */
    function get_end() {
        return $end = get_post_meta( $this->id, '_bkap_end', true );
    }
    
    /**
     * Returns the Time Slot
     * 
     * @return Time Slot
     * @since 4.1.0
     */
    function get_time() {
        $global_settings = json_decode( get_option( 'woocommerce_booking_global_settings' ) );
         
        $time_format = $global_settings->booking_time_format;
         
        // Commenting since we need 24 hour format for comparision
        //$time_format = ( $time_format === '12' ) ? 'h:i A' : 'H:i';
        $time_format = 'H:i';
        $start_time = date( $time_format, strtotime( $this->get_start() ) );
         
        $end_time = date( $time_format, strtotime( $this->get_end() ) );

        if ( $end_time === '' || $end_time === '00:00' ) {
            return $start_time;
        }
        return "$start_time - $end_time";
    }
    
    /**
     * Returns the Start Date
     * 
     * @return Date in the format set in Booking->Settings->Date Format
     * @since 4.2.0
     */
    function get_start_date() {
         
        $start = $this->get_start();
         
        $global_settings = json_decode( get_option( 'woocommerce_booking_global_settings' ) );
         
        $date_formats       = bkap_get_book_arrays( 'bkap_date_formats' );
        // get the global settings to find the date formats
        $global_settings    = json_decode( get_option( 'woocommerce_booking_global_settings' ) );
        $date_format_set    = $date_formats[ $global_settings->booking_date_format ];
        return date( $date_format_set, strtotime( $start ) );
         
    }
    
    /**
     * Returns the End Date
     * 
     * @return Date in the format set in Booking->Settings->Date Format
     * @since 4.2.0
     */
    function get_end_date() {
    
        $end_date = '';
         
        $start = $this->get_start();
        $end = $this->get_end();
         
        if ( $start !== $end ) {
             
            $global_settings = json_decode( get_option( 'woocommerce_booking_global_settings' ) );
    
            $date_formats       = bkap_get_book_arrays( 'bkap_date_formats' );
            // get the global settings to find the date formats
            $global_settings    = json_decode( get_option( 'woocommerce_booking_global_settings' ) );
            $date_format_set    = $date_formats[ $global_settings->booking_date_format ];
            $end_date = date( $date_format_set, strtotime( $end ) );
        }
         
        return $end_date;
    }
    
    /**
     * Returns Start Time
     * 
     * @return Start Time as per format set in Booking->Settings->Time Format
     * @since 4.2.0
     */
    function get_start_time() {
    
        $start_time = '';
        $global_settings = json_decode( get_option( 'woocommerce_booking_global_settings' ) );
         
        $time_format = $global_settings->booking_time_format;
        $time_format = ( $time_format === '12' ) ? 'h:i A' : 'H:i';
         
        if ( '000000' !== substr( $this->get_start(), 8 ) ) {
            $start_time = date( $time_format, strtotime( $this->get_start() ) );
        }
         
        return $start_time;
    }
    
    /**
     * Returns Start Time
     * 
     * @return Start Time as per format set in Booking->Settings->Time Format
     * @since 4.2.0
     */
    function get_end_time() {
    
        $end_time = '';
        $global_settings = json_decode( get_option( 'woocommerce_booking_global_settings' ) );
    
        $time_format = $global_settings->booking_time_format;
        $time_format = ( $time_format === '12' ) ? 'h:i A' : 'H:i';
         
        if ( '000000' !== substr( $this->get_end(), 8 ) ) {
            $end_time = date( $time_format, strtotime( $this->get_end() ) );
        }
         
        return $end_time;
    }
    
    /**
     * Returns the Booked Quantity
     * 
     * @return integer $quantity
     * @since 4.2.0
     */
    function get_quantity() {
        return get_post_meta( $this->id, '_bkap_qty', true );
    }
    
    /**
     * Returns the Booked Cost
     * 
     * @return integer $cost
     * @since 4.2.0
     */
    function get_cost() {
        return get_post_meta( $this->id, '_bkap_cost', true );
    }
    
    /**
     * Returns the Variation ID
     * 
     * @return integer $variation_id
     * @since 4.4.0
     */
    function get_variation_id() {
        return get_post_meta( $this->id, '_bkap_variation_id', true );
    }
    
    /**
     * Returns the Item ID for the booked product
     * 
     * @return integer $item_id
     * @since 4.4.0
     */
    function get_item_id() {
        return get_post_meta( $this->id, '_bkap_order_item_id', true );
    }
    
    /**
     * Returns resource
     * 
     * @return integer $resource_id - Resource used in the booking
     * @since 4.6.0
     */
    function get_resource() {
        $resource = get_post_meta( $this->id, '_bkap_resource_id', true );
    
        return $resource;
    }
    
    /**
     * Returns resource title
     * 
     * @return string $resource_title - Title of the resource being used in the booking.
     * @since 4.6.0
     */
    function get_resource_title() {
        $resource_id = get_post_meta( $this->id, '_bkap_resource_id', true );
    
        $resource_title = "";
        if ( $resource_id != "" ) {
            $resource_title = get_the_title( $resource_id );
        }
    
        return $resource_title;
    }
}
?>
API documentation generated by ApiGen