···437437 });
438438439439 // ------------------------------------------------------//
440440- const disabledDates = []; // we will need to access this in multiple functions
441441-442442- // ------------------------------------------------------//
443440 // This handles 'datepicker' in 'shipping'
444441 const shippingSelector = '#checkout-shipping-options';
445442 ready(shippingSelector, (shippingOptionsElement) => {
···476473 // Create calendar and attach date picker logic here
477474 let dailyDeliveryLimit = 250;
478475 const dailySlotValues = {};
476476+ const disabledDates = [];
479477480478 // get delivery dates from middleware
481479 fetch('https://purrform-apps-027e.onrender.com/deliveryDates')
···798796 const deliveryInstructions = data.customerMessage;
799797800798 if (deliveryInstructions?.trim()) {
801801- // need to check if the date is valid
802802- if (!deliveryInstructions.includes(' | ')) {
803803- missingWarn.textContent =
804804- 'Invalid delivery date. Please edit your shipping details above and select a valid delivery date.';
805805- missingWarn.style.display = 'block';
806806- return;
807807- }
808808-809809- const date = deliveryInstructions.split(' | ')[0];
810810- if (disabledDates.includes(date)) {
811811- missingWarn.textContent =
812812- 'This delivery date cannot be selected. Please edit your shipping details above and select another delivery date.';
813813- missingWarn.style.display = 'block';
814814- return;
815815- }
816816-817817- // check if the date is in the past
818818- const today = new Date();
819819- const selectedDate = new Date(date);
820820- if (selectedDate < today) {
821821- missingWarn.textContent =
822822- 'This delivery date is in the past. Please edit your shipping details above and select another delivery date.';
823823- missingWarn.style.display = 'block';
824824- return;
825825- }
826826-827799 paymentContinueButton.click();
828800 } else {
829801 missingWarn.style.display = 'block';