You can limit the allowed dates for the DatePicker Field Type so that only specific dates are accepted (e.g. today’s date onward, or up to 3 months from today).
Add the following PHP snippets to your current WordPress Theme’s functions.php file to limit the DatePicker Field to only accept dates from today’s date forward. You can apply other DatePicker rules (jQuery UI) using the below method.
View Code
Where in the functions.php can I add this? Just anywhere or do I need to place it somewhere specific?
Hi cynthia, anywhere within your Theme’s functions.php file will work. If your functions.php already contains < ?php and ?> start and ending lines then don’t include them. I hope this helps 🙂
When I add this to the child theme function.php, the site breaks. I need to make the date-picker one day ahead. I already have a function in the file, so I stripped off the beginning . Is that wrong?
Hi Mary, if you’re pasting the above PHP snippet into your Theme’s functions.php file please remove the opening and ending lines:
< ?php ... ?>
Thx – I actually worked this out and submitted a request to limit timepicker to open hrs of the store – started another topic for that – hope you can help with that
Nice! I’m up against the wall preparing for WooCommerce 3.0 (including a WCM Plugin update) but once that all settles down after April 4 I’ll be back on the w.org forums helping out 🙂
Ooo – My target release date for this website is April 1 – can you please direct me to somebody who can solve this – I don’t want to miss my deadline. thanks
Hi Mary, unfortunately it’s a free Plugin so there’s no dedicated support for it. I’d ping your topic on w.org asking for help from the user community; there are 40,000+ active installs so some very smart users who know the ins and outs of the Plugin 🙂
https://wordpress.org/support/plugin/woocommerce-checkout-manager
i realize that – the problem is I have bought lots of paid plugins that are a disappointment. i know you don’t have time – but hopefully your link will provide some insight. I don’t think my problem is particularly complicated – I just need how to exactly code the fix. too bad – I need to look for a plugin that can solve my problem before April 1. Maybe I won’t – and then I get a bad rep and so do you. Thanks anyway.
Hi Mary, you may need to purchase a Plugin then that matches your requirements (and that is also actively supported and provides customisations if required), I wish you luck but do ping your topic as it’s pretty active during the week 🙂
How do I restrict time ranges for the timepicker?
Hi Tom, can you open a new support topic in w.org so I can respond there 🙂
Hi,
Managed to sort it myself. I can send you the code if you like?
Nice work! Sure! I’ll add a new code snippet as I’m sure it will help others, you can comment here 🙂
Just add this to your functions.php to alter the minutes interval and limit selectable hours in the day
/* WC Checkout manager only allow certain times with 30 minute intervals*/
add_filter( ‘wooccm_timepicker_jquery_args’, ‘custom_wooccm_js_timepicker_billing_args’,10,2 );
function custom_wooccm_js_timepicker_billing_args( $args, $btn) {
$args .= ‘
,
minutes: {interval: 30, manual: [30] },
showPeriod: true,
hours: { starts: 08, ends: \’17\’ }
‘;
return $args;
}