Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #806748

    Hi for my site’s reservation form, please can I ask how I can disable just a single specific date for selection? On the forums I’ve managed to find some semi solutions, but it was to disable a day of the week throughout the year,

    I’m hoping to disable just a specific date such as 18-06-2017.

    Thank you!

    #807505

    Hey Jon,

    Please use a child theme – http://kriesi.at/documentation/enfold/using-a-child-theme/ then copy unmodified enfold/framework/php/class-form-generator.php file and paste it inside enfold-child folder and find following at the top and remove it (please do not remove PHP opening tag)

    
    if (  ! defined( 'AVIA_FW' ) ) exit( 'No direct script access allowed' );
    

    and then add following code to Functions.php file of your child theme

    
    require( 'class-form-generator.php' );
    

    Then open class-form-generator.php file in your child theme and find

    
    echo 'jQuery(document).ready(function(){ jQuery(".avia_datepicker").datepicker({
    

    then add following right below that line

    
        beforeShowDay: function(date){
            var string = jQuery.datepicker.formatDate('2017-06-18', date);
            return [$.inArray(string, array) == -1];
        }

    Best regards,
    Yigit

    #807580

    Thanks very much for your kind help, Yigit!
    Unfortunately, I now have an error message when I added in the above line.

    Parse error: syntax error, unexpected T_LNUMBER, expecting ‘,’ or ‘;’ in /home/thaivill/public_html/wp-content/themes/enfold-child/class-form-generator.php on line 493

    I’ve attached my php file for your kind reference. Is it because it’s been modified from before? Here’s the current line of code from that section

    echo ‘jQuery(document).ready(function(){ jQuery(“.avia_datepicker”).datepicker({
    minDate: 1,
    beforeShow: function(input, inst) {
    jQuery(“#ui-datepicker-div”).addClass(this.id);
    inst.dpDiv.addClass(“avia-datepicker-div”);
    },
    showButtonPanel: true,

    Not quite sure where I went wrong there.

    #808036

    Hi,

    Please replace the content of class-form-generator.php file on your child theme with this one – https://pastebin.com/iHSatnc4

    Best regards,
    Yigit

    #808086

    Hey thanks, Yigit, I truly appreciate your help as always!
    After doing so, I’m getting the following error:

    Parse error: syntax error, unexpected T_LNUMBER, expecting ‘,’ or ‘;’ in /home/thaivill/public_html/wp-content/themes/enfold-child/class-form-generator.php on line 498

    I’ve attached my previous and current classform generator php file. Not sure why I’m getting the error for the life of me. :(

    #808087

    Hey!

    Can you please post FTP logins here privately and let us know the exact date you would like to disable, in case it is not 2017-06-18? :)

    Cheers!
    Yigit

    #808142

    on my Enfold the date is set to DD/MM/YY why can we use here the date in that form: 2017-06-18

    you see the excluded days in the form day/month/year – month without a leading Zero

    see solution down under :lol:

    • This reply was modified 7 years, 6 months ago by Guenni007.
    #808175

    by the way – here we can also set start and end time as well:

    i had to make two functions of it because the one must load before helper datepicker starts:

    and think of the month without leading zero !

    function exclude_datepicker_dates() {
    ?>
    <script type="text/javascript">
    var unavailableDates = ["17/12/2017", "12/12/2017", "18/6/2017"];
    
    function unavailable(date) {
    dmy = date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear();
    if (jQuery.inArray(dmy, unavailableDates) == -1) {
    return [true, ""];
    } else {
    return [false, "", "Unavailable"];
    }
    }
     </script>
    <?php
    }
    add_action('wp_footer', 'exclude_datepicker_dates', 10);
    
    function my_datepicker_defaults() {
    ?>
     <script type="text/javascript">
        jQuery(document).ready(function(){ 
            jQuery.datepicker.setDefaults({
    	beforeShowDay: unavailable,
            minDate: 0,
            maxDate: "+12m"
                });
        });   
     </script>
    <?php
    }
    add_action('wp_footer', 'my_datepicker_defaults', 20);
    .ui-datepicker td[title="Unavailable"] {
        background: rgba(120, 255, 180, 0.3);
    }
    #808177
    #808188

    new solution above . Only for functions.php child-theme nothing to copy or replace.

    • This reply was modified 7 years, 6 months ago by Guenni007.
    #808410

    Hi,

    Thanks for sharing @guenni007 :-)

    Best regards,
    Rikard

    #808528

    @guenni007, I can’t tell you how much I appreciate your awesome help! It’s one of the reasons why I love this theme so much, because of awesome ppl like you on this forum and on the Facebook Enfold Users page. Thank you from the bottom of my heart for taking the time to help. You are putting good out into this world! Thank you, thank you, thank you!

    And also thank you to Yigit, Rikard and Enfold team for always providing the best wp support in the market!

    • This reply was modified 7 years, 6 months ago by jasksks.
    #808647

    Thanks – but the other way will work too.
    But i like those snippets in functions.php because i don’t like to think of it when parent theme was updating, and having that bad feeling there might be changings on those edited files in child-theme folder.

    #808650

    Hi!

    We’re glad that everyone was able to help out. :)

    Do you still need further help with this topic, or can we close this thread?

    Cheers!
    Sarah

    #808996

    Hi Sarah, yes please do. Thank you very much!

    #809222

    Great!

    For your information, you can take a look at Enfold documentation here – http://kriesi.at/documentation/enfold/

    And if there are features that you wish Enfold had, you can request them and vote the requested ones here – https://kriesi.at/support/enfold-feature-requests/

    For any other questions or issues, feel free to post them here on the forum and we will gladly try to help you.

    Thank you for using Enfold.

    Cheers!
    Sarah

Viewing 16 posts - 1 through 16 (of 16 total)
  • The topic ‘Disable single date datepicker’ is closed to new replies.