You’re really close — and it’s great you’re working through this with the native Shopify date picker snippet.
To get your logic working reliably, you’ll want to make sure:
The minDate setting is dynamically set before the calendar renders.
The beforeShowDay function continues to block Sundays.
Here’s a version that should more accurately reflect your intent:
$(function() { const now = new Date(); const day = now.getDay(); const hour = now.getHours(); let bufferDays = 0; // Determine buffer based on logic if (day === 0) { bufferDays = 1; // Sunday → block next day (Monday) } else if (day === 6 && hour < 13) { bufferDays = 1; // Saturday before 1pm → block next day } else if (day === 6 && hour >= 13) { bufferDays = 2; // Saturday after 1pm → block next 2 days } else if (hour >= 13) { bufferDays = 1; // Mon–Fri after 1pm → block next day } $(“#datepicker”).datepicker({ minDate: bufferDays, beforeShowDay: function(date) { return [date.getDay() !== 0]; // disable Sundays } }); });
You should also make sure the #datepicker input exists on the page when this script runs — or wrap it in a check with something like if ($(‘#datepicker’).length).
If you ever want a more scalable approach (e.g. if dates vary by product or shipping method), Flare is one app that can handle these rules automatically without needing custom jQuery — but your current path is perfect if you’re just customizing a basic theme.
Let me know if you need help debugging further — happy to assist!