Exclude Specific Dates from a booking form

Home Forums Quform WordPress Exclude Specific Dates from a booking form

This topic is: not resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13763
    timothypbrand
    Participant

    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
    Tim

    #13783
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #13788
    timothypbrand
    Participant

    Hi 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.
    #

    #13789
    timothypbrand
    Participant

    Sorry 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.
    #

    #13807
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy