Home › Forums › Quform WordPress › Exclude Specific Dates from a booking form
- This topic has 4 replies, 2 voices, and was last updated 9 years, 2 months ago by Ally.
- AuthorPosts
- February 3, 2015 at 3:59 am #13763timothypbrandParticipant
Hi Themecatcher
I have a client that wants to exclude bookings on Mondays and Tuesdays for their restaurant.
Could you help out with possible suggestions on how to do this?
I have the dd/mm/yy and datepicker used for this.
many thanks
Cheers
TimFebruary 4, 2015 at 3:01 pm #13783AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 4, 2015 at 11:46 pm #13788timothypbrandParticipantHi Ally
Many thanks for your reply.
I added this code into the theme functions.php and the entire site went blank.
Hopefully I am not doing anything wrong.
I made sure I copied all the code in.
See below:
<?php// ensure EXT is defined
if ( ! defined( 'EXT' ) ) {
define( 'EXT', '.php' );
}#
# See: wpgrade-config.php -> include-paths for additional theme specific
# function and class includes
#// ensure REQUEST_PROTOCOL is defined
if ( ! defined('REQUEST_PROTOCOL')) {
if (is_ssl()) {
define( 'REQUEST_PROTOCOL', 'https:' );
} else {
define( 'REQUEST_PROTOCOL', 'http:' );
}
}// Theme specific settings
// -----------------------// add theme support for post formats
// child themes note: use the after_setup_theme hook with a callback
// right now no post formats
//$formats = array( 'video', 'audio', 'gallery', 'image', 'quote', 'link', 'chat', 'aside', );
//add_theme_support( 'post-formats', $formats );// Initialize system core
// ----------------------require_once 'wpgrade-core/bootstrap' . EXT;
function my_form_date_validation($valid, $value, $element) {
$time = strtotime("{$value['year']}-{$value['month']}-{$value['day']}");
$dayOfWeek = date('l', $time);if ($dayOfWeek == 'Monday' || $dayOfWeek == 'Tuesday') {
$element->addError('Bookings are not available on Monday or Tuesday');
$valid = false;
}return $valid;
}
add_filter('iphorm_element_valid_iphorm_1_1', 'my_form_date_validation', 10, 3);function my_datepicker_options($options, $dpMinYear, $dpMaxYear, $element) {
return "{
beforeShowDay: function (date) {
var day = date.getDay(), Monday = 1, Tuesday = 2;
var closedDays = [[Monday], [Tuesday]];for (var i = 0; i < closedDays.length; i++) {
if (day == closedDays[i][0]) {
return [false, '', 'Bookings are not available on Monday or Tuesday'];
}
}return [true];
}
}";
}
add_filter('iphorm_datepicker_options_iphorm_1_1', 'my_datepicker_options', 10, 4);#
# Please perform any initialization via options in wpgrade-config and
# calls in wpgrade-core/bootstrap. Required for testing.
#
February 5, 2015 at 12:24 am #13789timothypbrandParticipantSorry I did add the element id as the following below:
<?php// ensure EXT is defined
if ( ! defined( 'EXT' ) ) {
define( 'EXT', '.php' );
}#
# See: wpgrade-config.php -> include-paths for additional theme specific
# function and class includes
#// ensure REQUEST_PROTOCOL is defined
if ( ! defined('REQUEST_PROTOCOL')) {
if (is_ssl()) {
define( 'REQUEST_PROTOCOL', 'https:' );
} else {
define( 'REQUEST_PROTOCOL', 'http:' );
}
}// Theme specific settings
// -----------------------// add theme support for post formats
// child themes note: use the after_setup_theme hook with a callback
// right now no post formats
//$formats = array( 'video', 'audio', 'gallery', 'image', 'quote', 'link', 'chat', 'aside', );
//add_theme_support( 'post-formats', $formats );// Initialize system core
// ----------------------require_once 'wpgrade-core/bootstrap' . EXT;
function my_form_date_validation($valid, $value, $element) {
$time = strtotime("{$value['year']}-{$value['month']}-{$value['day']}");
$dayOfWeek = date('l', $time);if ($dayOfWeek == 'Monday' || $dayOfWeek == 'Tuesday') {
$element->addError('Bookings are not available on Monday or Tuesday');
$valid = false;
}return $valid;
}
add_filter('iphorm_element_valid_iphorm_1_4', 'my_form_date_validation', 10, 3);function my_datepicker_options($options, $dpMinYear, $dpMaxYear, $element) {
return "{
beforeShowDay: function (date) {
var day = date.getDay(), Monday = 1, Tuesday = 2;
var closedDays = [[Monday], [Tuesday]];for (var i = 0; i < closedDays.length; i++) {
if (day == closedDays[i][0]) {
return [false, '', 'Bookings are not available on Monday or Tuesday'];
}
}return [true];
}
}";
}
add_filter('iphorm_datepicker_options_iphorm_1_4', 'my_datepicker_options', 10, 4);#
# Please perform any initialization via options in wpgrade-config and
# calls in wpgrade-core/bootstrap. Required for testing.
#February 9, 2015 at 10:54 am #13807AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.