| @@ -154,9 +154,9 @@ | ||
| 154 | 154 | $this->add_control( |
| 155 | 155 | 'booking_hide_if_сhildrens_allowed_field', |
| 156 | 156 | [ |
| 157 | 157 | 'label' => esc_html__('Childrens allowed field hide', 'wpdirectorykit'), |
| 158 | - 'type' => Controls_Manager::SWITCHER, | |
| 158 | + 'type' => Controls_Manager::HIDDEN, | |
| 159 | 159 | 'none' => esc_html__('Yes', 'wpdirectorykit'), |
| 160 | 160 | 'block' => esc_html__('No', 'wpdirectorykit'), |
| 161 | 161 | 'return_value' => 'yes', |
| 162 | 162 | 'default' => '', |
| @@ -173,8 +173,20 @@ | ||
| 173 | 173 | 'return_value' => 'yes', |
| 174 | 174 | 'default' => '', |
| 175 | 175 | ] |
| 176 | 176 | ); |
| 177 | + | |
| 178 | + $this->add_control( | |
| 179 | + 'booking_hide_count_childs_field', | |
| 180 | + [ | |
| 181 | + 'label' => esc_html__('Hide booking field count childs', 'wpdirectorykit'), | |
| 182 | + 'type' => Controls_Manager::SWITCHER, | |
| 183 | + 'none' => esc_html__('Yes', 'wpdirectorykit'), | |
| 184 | + 'block' => esc_html__('No', 'wpdirectorykit'), | |
| 185 | + 'return_value' => 'yes', | |
| 186 | + 'default' => '', | |
| 187 | + ] | |
| 188 | + ); | |
| 177 | 189 | $this->end_controls_section(); |
| 178 | 190 | } |
| 179 | 191 | |
| 180 | 192 | /** |
| @@ -189,45 +201,141 @@ | ||
| 189 | 201 | protected function render() { |
| 190 | 202 | $settings = $this->get_settings(); |
| 191 | 203 | global $wdk_listing_id; |
| 192 | 204 | |
| 205 | + $validation_form_email = false; | |
| 206 | + $validation_form_message = false; | |
| 207 | + | |
| 208 | + foreach ($settings['form_fields'] as $field) { | |
| 209 | + | |
| 210 | + $field_name = ''; | |
| 211 | + | |
| 212 | + if(!empty($field['field_id'])) { | |
| 213 | + $field_name = $field['field_id']; | |
| 214 | + } | |
| 215 | + | |
| 216 | + if(empty($field_name)) { | |
| 217 | + $field_name = $field['field_label']; | |
| 218 | + } | |
| 219 | + | |
| 220 | + if(empty($field_name)) { | |
| 221 | + $field_name = $field['placeholder']; | |
| 222 | + } | |
| 223 | + | |
| 224 | + if(strtolower($field_name) == 'email') { | |
| 225 | + $validation_form_email = true; | |
| 226 | + } | |
| 227 | + | |
| 228 | + if(strtolower($field_name) == 'message') { | |
| 229 | + $validation_form_message = true; | |
| 230 | + } | |
| 231 | + } | |
| 232 | + | |
| 233 | + if(!$validation_form_email || !$validation_form_message) { | |
| 234 | + $this->content ['wlisting_fields'] .= '<div class="elementinvader_addons_for_elementor_f_group elementinvader_addons_for_elementor_f_group_el_guests" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;">'; | |
| 235 | + $this->content ['wlisting_fields'] .= '<div role="alert" class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger">'.esc_html__('Field with ID "email" and "message" missing, please add fields with this ID-s or form can\'t work properly','wpdirectorykit').'</div>'; | |
| 236 | + $this->content ['wlisting_fields'] .= '</div>'; | |
| 237 | + } | |
| 238 | + | |
| 239 | + | |
| 193 | 240 | $post_id = get_the_ID(); |
| 194 | 241 | if(isset($wdk_listing_id)){ |
| 195 | 242 | $this->content ['wlisting_fields'] .= '<input name="listing_id" type="hidden" value="'.$wdk_listing_id.'" >'; |
| 196 | 243 | $this->content ['wlisting_fields'] .= '<input name="listing_link" type="hidden" value="'.get_permalink(wmvc_show_data('post_id', $post_id)) .'" >'; |
| 197 | 244 | } |
| 245 | + wp_enqueue_script( 'wdk-booking-calculator-price' ); | |
| 198 | 246 | if(function_exists('run_wdk_bookings')) { |
| 199 | 247 | global $Winter_MVC_wdk_bookings; |
| 200 | 248 | |
| 201 | 249 | $Winter_MVC_wdk_bookings->model('calendar_m'); |
| 202 | 250 | $Winter_MVC_wdk_bookings->model('reservation_m'); |
| 203 | - $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_pagination(NULL, NULL, array('post_id' => $wdk_listing_id)); | |
| 251 | + $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_pagination(NULL, NULL, array('post_id' => $wdk_listing_id, 'is_activated' => 1)); | |
| 204 | 252 | |
| 205 | 253 | $dates = $Winter_MVC_wdk_bookings->reservation_m->get_enabled_dates($wdk_listing_id); |
| 206 | 254 | $dates = (str_replace("'",'',join(' ',$dates))); |
| 207 | - | |
| 255 | + | |
| 256 | + /* booking price selector */ | |
| 257 | + $this->content ['wlisting_fields'] ='<div class="elementinvader_addons_for_elementor_f_group elementinvader_addons_for_elementor_f_group_el_guests" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;"> | |
| 258 | + <div class="wdk_booking_auto_calculate_price"></div> | |
| 259 | + </div>'. $this->content ['wlisting_fields']; | |
| 260 | + | |
| 261 | + if(wdk_get_option('wdk_bookings_enable_woocommerce_payments') && wc_get_cart_url() == home_url()) { | |
| 262 | + $this->content ['wlisting_fields'] .= '<div class="elementinvader_addons_for_elementor_f_group elementinvader_addons_for_elementor_f_group_el_guests" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;"> | |
| 263 | + <div class="elementinvader_addons_for_elementor_alert elementinvader_addons_for_elementor_alert-danger">'.esc_html__('Missing cart page in WooCommerce, please configure by guide','wpdirectorykit').'</div> | |
| 264 | + </div>'; | |
| 265 | + } | |
| 266 | + | |
| 267 | + | |
| 208 | 268 | if( $calendar && isset($calendar[0]) ) |
| 209 | - if( !is_user_logged_in() && ((isset($settings['booking_hide_if_not_login']) && !$settings['booking_hide_if_not_login'] == 'yes') || wmvc_show_data('is_disable_for_not_login',$calendar[0],false, TRUE, TRUE))){ | |
| 269 | + if( !is_user_logged_in() && ((isset($settings['booking_hide_if_not_login']) && !$settings['booking_hide_if_not_login'] == 'yes') || wmvc_show_data('is_disable_for_not_login',$calendar[0],false, TRUE, TRUE) || wdk_get_option('wdk_booking_disable_for_not_login'))){ | |
| 210 | 270 | $this->content ['wlisting_fields'] .= '<div class="elementinvader_addons_for_elementor_f_group elementinvader_addons_for_elementor_f_group_el_guests" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;"> |
| 211 | 271 | <a href="'.wdk_login_url(wdk_current_url()).'" class="wdk-booking"> |
| 212 | 272 | '.esc_html__('For Booking please login','wpdirectorykit').' |
| 213 | - </div></a>'; | |
| 273 | + </a></div>'; | |
| 214 | 274 | } else { |
| 215 | 275 | $calendar = $calendar[0]; |
| 216 | - $options = array(''=>esc_html__('Select Guests','wpdirectorykit'), '1'=>'1', '2'=>'2', '3'=>'3', '4'=>'4', '5+'=>'5+'); | |
| 217 | - $output ='<div class="elementinvader_addons_for_elementor_f_group elementinvader_addons_for_elementor_f_group_el_guests" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;">'; | |
| 218 | - $output .='<select name="guests_number" id="booking_guests_number" type="select" class="elementinvader_addons_for_elementor_f_field" value="'.wmvc_show_data('guests_number', $_GET).'">'; | |
| 219 | - foreach ($options as $key => $option){ | |
| 220 | - $output .= '<option value="'.esc_attr($key).'">'.esc_html($option).'</option>'; | |
| 276 | + | |
| 277 | + if(!empty($calendar->guests)) { | |
| 278 | + $options = range(1, intval($calendar->guests)); | |
| 279 | + } elseif(intval(wdk_get_option('wdk_bookings_max_guests')) > 0) { | |
| 280 | + $options = range(1, intval(wdk_get_option('wdk_bookings_max_guests'))); | |
| 281 | + } else { | |
| 282 | + $options = range(1, 10); | |
| 283 | + } | |
| 284 | + | |
| 285 | + if(empty($calendar->is_guests_disabled)) { | |
| 286 | + | |
| 287 | + if($settings['booking_hide_count_childs_field'] != 'yes' && !empty($calendar->is_children_acceptable) ) { | |
| 288 | + $output ='<div class="elementinvader_addons_for_elementor_f_group elementinvader_addons_for_elementor_f_group_el_guests" style="width: 50%;-webkit-flex: 0 0 50%;flex: 0 0 50%;">'; | |
| 289 | + } else { | |
| 290 | + $output ='<div class="elementinvader_addons_for_elementor_f_group elementinvader_addons_for_elementor_f_group_el_guests" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;">'; | |
| 291 | + } | |
| 292 | + | |
| 293 | + $output .='<select name="guests_number_adults" id="guests_number_adults" type="select" class="elementinvader_addons_for_elementor_f_field" value="'.wmvc_show_data('guests_number', $_GET).'">'; | |
| 294 | + $output .= '<option value="">'.esc_html__('Adults','wpdirectorykit').'</option>'; | |
| 295 | + foreach ($options as $key => $option){ | |
| 296 | + if(!next($options)) { | |
| 297 | + $output .= '<option value="'.esc_attr($option).'+">'.esc_html($option).'+</option>'; | |
| 298 | + }else { | |
| 299 | + $output .= '<option value="'.esc_attr($option).'">'.esc_html($option).'</option>'; | |
| 300 | + } | |
| 221 | 301 | } |
| 222 | - $output .='</select> | |
| 223 | - </div>'; | |
| 302 | + $output .='</select> | |
| 303 | + </div>'; | |
| 224 | 304 | |
| 225 | - $this->content ['wlisting_fields'] .= $output; | |
| 305 | + if($settings['booking_hide_count_childs_field'] != 'yes' && !empty($calendar->is_children_acceptable)) { | |
| 306 | + $output .='<div class="elementinvader_addons_for_elementor_f_group elementinvader_addons_for_elementor_f_group_el_guests" style="width: 50%;-webkit-flex: 0 0 50%;flex: 0 0 50%;">'; | |
| 307 | + $output .='<select name="guests_number_childs" id="guests_number_childs" type="select" class="elementinvader_addons_for_elementor_f_field" value="'.wmvc_show_data('guests_number', $_GET).'">'; | |
| 308 | + $output .= '<option value="">'.esc_html__('Childs','wpdirectorykit').'</option>'; | |
| 309 | + foreach ($options as $key => $option){ | |
| 310 | + if(!next($options)) { | |
| 311 | + $output .= '<option value="'.esc_attr($option).'+">'.esc_html($option).'+</option>'; | |
| 312 | + } else { | |
| 313 | + $output .= '<option value="'.esc_attr($option).'">'.esc_html($option).'</option>'; | |
| 314 | + } | |
| 315 | + } | |
| 316 | + $output .='</select> | |
| 317 | + </div>'; | |
| 318 | + } | |
| 319 | + | |
| 320 | + $this->content ['wlisting_fields'] .= $output; | |
| 321 | + } | |
| 226 | 322 | |
| 323 | + | |
| 227 | 324 | $attr = ''; |
| 228 | - if(get_option('wdk_bookings_calendar_single')) { | |
| 325 | + if(get_option('wdk_bookings_calendar_single') && !wmvc_show_data('is_hour_enabled',$calendar, false)) { | |
| 229 | 326 | $attr = "data-wdksingle = 'true'"; |
| 327 | + } else { | |
| 328 | + | |
| 329 | + $custom_css = '.daterangepicker .drp-calendar.left .calendar-table::after { | |
| 330 | + content: "'.__('Please select from date/time','wpdirectorykit').'"; | |
| 331 | + }'; | |
| 332 | + | |
| 333 | + $custom_css .= '.daterangepicker .drp-calendar.right .calendar-table::after { | |
| 334 | + content: "'.__('Please select to date/time','wpdirectorykit').'"; | |
| 335 | + }'; | |
| 336 | + | |
| 337 | + wp_add_inline_style( 'daterangepicker', $custom_css); | |
| 230 | 338 | } |
| 231 | 339 | |
| 232 | 340 | if(!wmvc_show_data('is_hour_enabled',$calendar, false)){ |
| 233 | 341 | $this->content ['wlisting_fields'] .= ' <div class="elementinvader_addons_for_elementor_f_group text elementinvader_addons_for_elementor_f_group_el_1" style="width: 50%;-webkit-flex: 0 0 50%;flex: 0 0 50%;"> |
| @@ -248,27 +356,46 @@ | ||
| 248 | 356 | </div> |
| 249 | 357 | '; |
| 250 | 358 | } |
| 251 | 359 | |
| 252 | - if($settings['booking_hide_if_сhildrens_allowed_field'] != 'yes') { | |
| 253 | - $this->content ['wlisting_fields'] .='<div class="elementinvader_addons_for_elementor_f_group checkbox elementinvader_addons_for_elementor_f_group_el_сhildrens" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;"> | |
| 254 | - <label for="сhildrens_allowed"> | |
| 255 | - <input name="сhildrens_allowed" id="сhildrens_allowed" type="checkbox" class="elementinvader_addons_for_elementor_f_field_checkbox" value="yes" placeholder="'.esc_attr__('Childrens allowed ','wpdirectorykit').'" > | |
| 256 | - '.esc_html__('Childrens ','wpdirectorykit').' | |
| 257 | - </label> | |
| 258 | - </div>'; | |
| 259 | - } | |
| 360 | + if(true && function_exists('wdk_booking_currency_symbol')){ | |
| 361 | + if(!empty($calendar->json_data_fees)) | |
| 362 | + $calendar_fees = json_decode($calendar->json_data_fees ); | |
| 363 | + | |
| 364 | + if(!empty($calendar_fees)) { | |
| 260 | 365 | |
| 261 | - if ($settings['booking_hide_if_pets_allowed_field'] != 'yes') { | |
| 366 | + foreach ($calendar_fees as $fee) { | |
| 367 | + if(!wmvc_show_data('is_activated', $fee, false,TRUE,TRUE)) continue; | |
| 368 | + | |
| 369 | + $field = wdk_generate_slug(strtolower(esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE)))); | |
| 370 | + | |
| 371 | + $readonly = ''; | |
| 372 | + if(wmvc_show_data('is_required', $fee, false,TRUE,TRUE)) { | |
| 373 | + $readonly = 'readonly disabled'; | |
| 374 | + } | |
| 375 | + | |
| 376 | + $this->content ['wlisting_fields'] .='<div class="elementinvader_addons_for_elementor_f_group checkbox fee_group" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;"> | |
| 377 | + <label for="'.esc_attr($field).'"> | |
| 378 | + <input name="fee_'.esc_attr($field).'" checked="checked" '.esc_attr($readonly).' id="'.esc_attr($field).'" type="checkbox" class="elementinvader_addons_for_elementor_f_field_checkbox fees_checkbox" value="yes" placeholder="'.esc_attr(wmvc_show_data('title', $fee,'-',TRUE,TRUE)).'" > | |
| 379 | + '.esc_html(wmvc_show_data('title', $fee,'-',TRUE,TRUE)).'<span class="fee_price"> ('.esc_html(wmvc_show_data('value', $fee,'-',TRUE,TRUE)).esc_html(apply_filters( 'wdk-currency-conversion/convert/symbol', wdk_booking_currency_symbol())).'/'. | |
| 380 | + ((isset($Winter_MVC_wdk_bookings->calendar_m->calculation_base[wmvc_show_data('calculation_base', $fee,'-',TRUE,TRUE)])) ? $Winter_MVC_wdk_bookings->calendar_m->calculation_base[wmvc_show_data('calculation_base', $fee,'-',TRUE,TRUE)] : 'per stay').')</span> | |
| 381 | + </label> | |
| 382 | + </div>'; | |
| 383 | + } | |
| 384 | + } | |
| 385 | + } | |
| 386 | + | |
| 387 | + if ($settings['booking_hide_if_pets_allowed_field'] != 'yes' && wmvc_show_data('is_pets_acceptable',$calendar, false)) { | |
| 262 | 388 | $this->content ['wlisting_fields'] .='<div class="elementinvader_addons_for_elementor_f_group checkbox elementinvader_addons_for_elementor_f_group_el_pets" style="width: 100%;-webkit-flex: 0 0 100%;flex: 0 0 100%;"> |
| 263 | 389 | <label for="pets_allowed"> |
| 264 | - <input name="pets_allowed" id="pets_allowed" type="checkbox" class="elementinvader_addons_for_elementor_f_field_checkbox" value="yes" placeholder="'.esc_attr__('Pets allowed ', 'wpdirectorykit').'" > | |
| 265 | - '.esc_html__('Pets ', 'wpdirectorykit').' | |
| 390 | + <input name="pets_allowed" id="pets_allowed" type="checkbox" class="elementinvader_addons_for_elementor_f_field_checkbox" value="yes" placeholder="'.esc_attr__('Pets allowed', 'wpdirectorykit').'" > | |
| 391 | + '.esc_html__('Pets', 'wpdirectorykit').' | |
| 266 | 392 | </label> |
| 267 | 393 | </div>'; |
| 268 | 394 | } |
| 269 | 395 | |
| 270 | 396 | wp_enqueue_script( 'daterangepicker-moment' ); |
| 397 | + | |
| 271 | 398 | wp_enqueue_script( 'daterangepicker' ); |
| 272 | 399 | wp_enqueue_style('daterangepicker'); |
| 273 | 400 | |
| 274 | 401 | |