You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have included a "min" value that can have two possible values depending on a specific condition. These values can either be from the current day or the following day. However, there is also an invalid array with some dates that cannot be selected.
If the current day's "min" value falls within the invalid date range, it should be ignored and the selection should be adjusted to the next valid date. Unfortunately, this is not happening because the "min" value is set to the current day. As a result, the invalid date array is being bypassed and the user is able to select today's date, which should not be the case.
``
// Function to set updated max and min date
let sameDayDeliveryEnable = {{settings.same_day_delivery}};
let cutoffHour = {{settings.cutoff_time_same_day_delivery}};
let earliestDeliveryDate = document.querySelector(".earliest-delivery-date");
let currentDateTime = new Date();
let currentHour = currentDateTime.getHours();
let todayDate = currentDateTime.toISOString().slice(0, 10);
let tomorrow = new Date(currentDateTime.getTime() + 24 * 60 * 60 * 1000);
let tomorrowDate = tomorrow.toISOString().slice(0, 10);
let maxYear = new Date();
maxYear.setFullYear(maxYear.getFullYear() + 1);
maxYear = maxYear.toISOString().slice(0, 10);
let maxRange, minRange;
// Set max date
maxRange = maxYear
// Set min date
if (currentHour < cutoffHour) {
if (sameDayDeliveryEnable) {
minRange = todayDate;
earliestDeliveryDate.innerHTML = todayDate;
} else {
minRange = tomorrowDate;
earliestDeliveryDate.innerHTML = tomorrowDate;
}
} else {
minRange = tomorrowDate;
earliestDeliveryDate.innerHTML = tomorrowDate;
}
// To get the last 5 disabled dates
let today = new Date();
let numberOfDaysOff = {{settings.minus_no_of_days}};
let dd = String(today.getDate()).padStart(2, '0');
console.log(dd);
let mm = String(today.getMonth() + 1).padStart(2, '0'); // 03
let yyyy = today.getFullYear();
let nextyyyy = today.getFullYear()+1;
let lastDayofMonth = new Date(yyyy,mm, 0).getDate();
I have included a "min" value that can have two possible values depending on a specific condition. These values can either be from the current day or the following day. However, there is also an invalid array with some dates that cannot be selected.
If the current day's "min" value falls within the invalid date range, it should be ignored and the selection should be adjusted to the next valid date. Unfortunately, this is not happening because the "min" value is set to the current day. As a result, the invalid date array is being bypassed and the user is able to select today's date, which should not be the case.
``
// Function to set updated max and min date
let sameDayDeliveryEnable = {{settings.same_day_delivery}};
let cutoffHour = {{settings.cutoff_time_same_day_delivery}};
let earliestDeliveryDate = document.querySelector(".earliest-delivery-date");
let currentDateTime = new Date();
let currentHour = currentDateTime.getHours();
let todayDate = currentDateTime.toISOString().slice(0, 10);
let tomorrow = new Date(currentDateTime.getTime() + 24 * 60 * 60 * 1000);
let tomorrowDate = tomorrow.toISOString().slice(0, 10);
let maxYear = new Date();
maxYear.setFullYear(maxYear.getFullYear() + 1);
maxYear = maxYear.toISOString().slice(0, 10);
let maxRange, minRange;
// Set max date
maxRange = maxYear
// To get the last 5 disabled dates
let today = new Date();
let numberOfDaysOff = {{settings.minus_no_of_days}};
let dd = String(today.getDate()).padStart(2, '0');
console.log(dd);
let mm = String(today.getMonth() + 1).padStart(2, '0'); // 03
let yyyy = today.getFullYear();
let nextyyyy = today.getFullYear()+1;
let lastDayofMonth = new Date(yyyy,mm, 0).getDate();
The text was updated successfully, but these errors were encountered: