Currently, the only dates that are greyed out are ones that are in the past.
If I only have an event on 26th and 27th November, for example, then I would like for all the other dates to be greyed out - or just to have a dropdown where the customer can select from the two dates (instead of using the calendar).
How would this be possible?
Thanks in advance!
beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 1)];
}
What I think the structure of my code needs to be:
I need to use a portion of Alex’s code of getAvailableHours in frontend_book.js
Name it getUnavailableDays and do something like:
getUnavailableDays function(selDate) {
$('#available-hours').empty(); //empties the array
I need to say the following in JSON (I have to learn how to do JSON, I need help here, in PHP I would say the following)
$TodayPlusMax=date('dd-MM-yyyy') ;
//EndDate
$MaxDate=strtotime(date('dd-MM-yyyy', strtotime($TodayPlusMax)). " +60 days");
$fullybookeddates = array();
while (strtotime($TodayPlusMax) <= strtotime($MaxDate)) {
Then I need to use the rest of Alex’s code of getAvailableHours up to if (response.length > 0) { is
I replace 'selected_date' with $TodayPlusMax (or I suppose ‘TodayPlusMax’)
And turn the if statement around
from
if (response.length > 0) {
to
if (response.length <1) {
Then I need to say the following in JSON (my PHP is here)
$fullybookeddates = "'".$TodayPlusMax."'";
$TodayPlusMax=strtotime(date('dd-MM-yyyy', strtotime($TodayPlusMax)) . " +1 day");
} else {
$fullybookeddates = ",'".$TodayPlusMax."'";
$TodayPlusMax=strtotime(date('dd-MM-yyyy', strtotime($TodayPlusMax)) . " +1 day");
}
THEN $fullybookeddates (or 'fullybookeddates') is my array for blacking out days
I think my logic is right. Can someone help me with JSON
Craig
var numOfDays = 60;
var populated = unavailableDays(numOfDays);
function unavailable(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" +date.getFullYear();
if ($.inArray(dmy, populated) < 0) {
return [true];
} else {
return [false];
}
}
function testAvailability(selDate) {
// Find the selected service duration (it is going to
// be send within the "postData" object).
var selServiceDuration = 15; // Default value of duration (in minutes).
$.each(GlobalVariables.availableServices, function(index, service) {
if (service['id'] == $('#select-service').val()) {
selServiceDuration = service['duration'];
}
});
// If the manage mode is true then the appointment's start
// date should return as available too.
var appointmentId = (FrontendBook.manageMode)
? GlobalVariables.appointmentData['id'] : undefined;
var postData = {
'service_id': $('#select-service').val(),
'provider_id': $('#select-provider').val(),
'selected_date': selDate,
'service_duration': selServiceDuration,
'manage_mode': FrontendBook.manageMode,
'appointment_id': appointmentId
};
// Make ajax post request and get the available hours.
var ajaxurl = GlobalVariables.baseUrl + 'appointments/ajax_get_available_hours';
jQuery.post(ajaxurl, postData, function(response) {
///////////////////////////////////////////////////////////////
console.log('Get Available Hours JSON Response:', response);
///////////////////////////////////////////////////////////////
if (!GeneralFunctions.handleAjaxExceptions(response));