I’m using Gravity Forms and the Gravity Forms WooCommerce Product Add-Ons plugin to add a delivery date to a product.
I want the customer to be able to select the following day if it is before 12 midday, but not if it is after midday (the products are only available in the UK).
This is what I’m using to grey out previous dates and also to disable Sundays, as there’s no delivery on Sundays:
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".datepicker").datepicker({ minDate:1, beforeShowDay: function(date)
{ var day = date.getDay(); return [(day != 0), '']; } }); });
</script>
I found this question/answer: JQuery UI Datepicker Disbale Next Day After 12pm
But I’m not sure how to isolate the code I need from that solution to just disable next-day delivery after midday, and not add all the other functionality. If anyone’s able to help me out I would be hugely grateful!
I use this tactic for local pickup date picker options. It’s been running on several client sites for several months with no complaints on accuracy!
First you need to get the current time of UK.
Then after you need to validate for sunday and midday time. If current time is ok (as per your conditions) then you need to set(visible) datepicker.
create file getUKTime.php
edit jquery function in your code