ID; global $post; if($post and $post->post_type == $this->get_main_post_type()) $translated_event_id = $post->ID; else $translated_event_id = $event_id; $tickets = isset($event->data->tickets) ? $event->data->tickets : array(); $dates = isset($event->dates) ? $event->dates : array($event->date); $booking_options = get_post_meta($event_id, 'mec_booking', true); if(!is_array($booking_options)) $booking_options = array(); // WC System $WC_status = (isset($settings['wc_status']) and $settings['wc_status'] and class_exists('WooCommerce')) ? true : false; $WC_booking_form = (isset($settings['wc_booking_form']) and $settings['wc_booking_form']) ? true : false; if($ticket_id) { $new_tickets = array(); foreach($tickets as $t_id => $ticket) { if((int) $t_id === (int) $ticket_id) { $new_tickets[$t_id] = $ticket; } } if(count($new_tickets)) $tickets = $new_tickets; } $occurrence_time = isset($dates[0]['start']['timestamp']) ? $dates[0]['start']['timestamp'] : strtotime($dates[0]['start']['date']); $default_ticket_number = 0; if(count($tickets) == 1) $default_ticket_number = 1; $book = $this->getBook(); $availability = $book->get_tickets_availability($event_id, $occurrence_time); $date_format = (isset($ml_settings['booking_date_format1']) and trim($ml_settings['booking_date_format1'])) ? $ml_settings['booking_date_format1'] : 'Y-m-d'; if(isset($event->data->meta['mec_repeat_type']) and $event->data->meta['mec_repeat_type'] === 'custom_days') $date_format .= ' '.get_option('time_format'); $midnight_event = $this->is_midnight_event($event); $book_all_occurrences = 0; if(isset($event->data) and isset($event->data->meta) and isset($event->data->meta['mec_booking']) and isset($event->data->meta['mec_booking']['bookings_all_occurrences'])) $book_all_occurrences = (int) $event->data->meta['mec_booking']['bookings_all_occurrences']; // User Booking Limits list($user_ticket_limit, $user_ticket_unlimited) = $book->get_user_booking_limit($event_id); // Show Booking Form Interval $show_booking_form_interval = (isset($settings['show_booking_form_interval'])) ? $settings['show_booking_form_interval'] : 0; if(isset($booking_options['show_booking_form_interval']) and trim($booking_options['show_booking_form_interval']) != '') $show_booking_form_interval = $booking_options['show_booking_form_interval']; if($show_booking_form_interval) { $filtered_dates = array(); foreach($dates as $date) { $date_diff = $this->date_diff(date('Y-m-d h:i a', current_time('timestamp', 0)), date('Y-m-d h:i a', $date['start']['timestamp'])); if(isset($date_diff->days) and !$date_diff->invert) { $minute = $date_diff->days * 24 * 60; $minute += $date_diff->h * 60; $minute += $date_diff->i; if($minute > $show_booking_form_interval) continue; } $filtered_dates[] = $date; } $dates = $filtered_dates; } $available_spots = 0; $total_spots = -1; foreach($availability as $ticket_id=>$count) { if(!is_numeric($ticket_id)) { $total_spots = $count; continue; } if($count != '-1') $available_spots += $count; else { $available_spots = -1; break; } } if($total_spots > 0) $available_spots = min($available_spots, $total_spots); // Date Selection Method $date_selection = (isset($settings['booking_date_selection']) and trim($settings['booking_date_selection'])) ? $settings['booking_date_selection'] : 'dropdown'; // Modal Booking $modal_booking = (isset($_GET['method']) and sanitize_text_field($_GET['method']) === 'mec-booking-modal'); wp_enqueue_script('mec-nice-select', $this->asset('js/jquery.nice-select.min.js')); ?>