Hi, looking for an solution for a pizza restaurant.
-> on a page we are using gravity form.
-> consumer add their pizza etc. and do their ordering
-> ordering times are just from wedn. till sonday from 12-8pm (how can i show the form just in this time period?)
-> or how can i hide now the form from monday - tuesday+ when the restaurant is closed?
Here is something I’ve put together for opening days from other various docs etc, I would think it would be about the same for times have a look at https://jqueryui.com/datepicker/ it will show you what you can do.
Take notice of the formId, fieldId, #ID
<script type='text/javascript'>
// Reservation javascript to disable in the future months weekends and certain days
// 0 = sun, 1 = mon, 2 = tues, 3 = wed 4 = thurs, 5 = fri, 6 = sat
// Dinner
jQuery(document).ready(function() {
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 3 && fieldId == 7 ) {
var daysToDisable = [0,1,2,3,5,6];
jQuery("#input_3_7").datepicker({
minDate: '0',
maxDate: '+6 M',
dateFormat: 'dd/mm/yy',
beforeShowDay: disableSpecificWeekDays
});
function disableSpecificWeekDays(date) {
var day = date.getDay();
for (i = 0; i < daysToDisable.length; i++) {
if (jQuery.inArray(day, daysToDisable) != -1) {
return [false];
}
}
return [true];
}}})
// Lunch
// 0 = sun, 1 = mon, 2 = tues, 3 = wed 4 = thurs, 5 = fri, 6 = sat
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 1 && fieldId == 7 ) {
var daysToDisable = [0,4,5,6];
jQuery("#input_1_7").datepicker({
minDate: '0',
maxDate: '+6 M',
dateFormat: 'dd/mm/yy',
beforeShowDay: disableSpecificWeekDays
});
function disableSpecificWeekDays(date) {
var day = date.getDay();
for (i = 0; i < daysToDisable.length; i++) {
if (jQuery.inArray(day, daysToDisable) != -1) {
return [false];
}
}
return [true];
}}})
});
</script>