Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #736302

    Hi! One more addition to the questions here and here: is there a way to disable all Tuesdays, except some? So, I want to make an exception to open on February 14 (Valentine’s day..). Once again, thanks!!

    #738133

    Hey lijndiensten!

    Thank you for using Enfold.

    Please replace the snippet with the following code.

    beforeShowDay: function(date) {
    			        var day = date.getDay();
    					if (date.getDate() == 14 && date.getMonth() == 1) {
    					   return [true, ""];
    				    }
    		        	return [(day != 2)];
    				},

    Regards,
    Ismael

    #738199

    Magnificent, thanks Ismael.

    As maybe a helpful reference to others, the total piece of code is as follows, allowing to disable given weekdays, make exceptions on those, and disable special dates (say, Christmas).

    beforeShowDay: function(date) {
                        var day = date.getDay();
    					if (date.getDate() == 14 && date.getMonth() == 1) {
    					   return [true, ""];
    				    }
                        function IsClosed(date) {
                        var day = date.getDate();
                        var month = date.getMonth() + 1;
                        return (day === 24 && month === 12) + (day === 25 && month === 12) + (day === 1 && month === 1) + (day === 2 && month === 1);
                        }
                        return [(day != 2 && !IsClosed(date))];
                    },
    #738263

    Hey!

    Thank you for sharing that as a reference.
    We do hope it will help someone at the end.

    Thanks a lot

    Best regards,
    Basilis

    #1414791

    This also works with years:

    beforeShowDay: function(date) {
    var day = date.getDay();
    
    function IsClosed(date) {
    
    var day = date.getDate();
    var month = date.getMonth() + 1;
    var year = date.getFullYear();
    
    return (day === 25 && month === 12 && year === 2023)+(day === 24 && month === 12 && year === 2024);
    }
    return [(!IsClosed(date))];
    },
    #1414804

    Hi,

    Thanks for sharing @blanquer :-)

    Best regards,
    Rikard

    #1414921

    one thing to mention on inserting these snippets to child-theme functions.php: Sometimes you had to set the priority of the function to be before loading of datepicker. So a 10 might be usefull as priority – f.e.:

    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);

    and to keep in mind – counting starts at zero : Sunday is Day: 0 of the week and

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Disable all Tuesdays, except some in datepicker’ is closed to new replies.