BirchPress无法自动选择时隙

时间:2018-10-11 20:26:13

标签: javascript php wordpress shortcode

我已经修改了BirchPress插件,不需要有人输入。应该自动选择第一个可用时间,并且在前端您不会看到选择时间的选项。所有这些看起来都很不错,除了您提交表单时,它说您需要选择时间。这是即时通讯使用的代码。我需要做些什么来解决此问题,以便它自动选择一个时间并像预期的那样隐藏它?

<?php
add_filter('birchschedule_view_bookingform_is_time_slots_select_field', function() {
 return true;
}, 20);
?>
<?php
add_filter('birchschedule_view_bookingform_validate_booking_info', function($errors){
 if(!empty($errors['birs_appointment_time']) && empty($errors['birs_appointment_date'])) {
 $errors['birs_appointment_date'] = 'Date is unavailable';
 unset($errors['birs_appointment_time']);
 }
 return $errors;
}, 20);
?>



Paste the following code in the JavaScript box.

(function($){
 birchpress.addAction('birchschedule.view.bookingform.onTimeOptionsLoadAfter', function(){
 $('#birs_appointment_timeoptions option:eq(1)').attr('selected', 'selected').trigger('change');
 $('#birs_appointment_timeoptions').hide();
 var optionsLen = $('#birs_appointment_timeoptions option').length;
 if(optionsLen === 1){
 $('#birs_appointment_date_error').html('Date is unavailable');
 $('#birs_appointment_date_error').show();
 } else {
 $('#birs_appointment_date_error').html('');
 $('#birs_appointment_date_error').hide();
 }
 });
})(jQuery);


Paste the following code in the [bpscheduler_booking_form] box.

#birs_appointment_form .birs_form_field.birs_appointment_time > label {
 display: none;
}
#birs_appointment_form #birs_appointment_timeoptions {
 border: none;
}

0 个答案:

没有答案