-
-
Save jessepearson/1db1b699c8bb2fc0207cbfd178d0d797 to your computer and use it in GitHub Desktop.
<?php // do not copy this line | |
/** | |
* Will make the Bookings calender default to the month with the first available booking. | |
*/ | |
add_filter( 'wc_bookings_calendar_default_to_current_date', '__return_false' ); |
Wanted to report that it works correctly for me if I use a custom function, as opposed to the shorthand above. Is in:
add_filter( 'wc_bookings_calendar_default_to_current_date', 'your_prefix_wc_bookings_calendar_default_to_current_date', 99 );
function your_prefix_wc_bookings_calendar_default_to_current_date(){
return false;
}
This helped. Thanks !
Is there a way to make this work in order to automatically select the first available time when picked a date?
@pares90 That would take additional JavaScript loaded via other means to select the first day and/or time.
Is there a way to make this work in order to automatically select the first available time when picked a date?
paste this on your theme's javascript file
//select the first available date of the calendar
function loadFrame() {
let availableDate = document.querySelectorAll(".single-product a.ui-state-default");
if ( document.contains(availableDate[0]) ) {
availableDate[0].click();
}
}
window.onload = setTimeout(loadFrame, 3000);
it will click on the first available date, 3 seconds after the page finishes to load
Why doesn't this work? add_filter( 'wc_bookings_calendar_default_to_current_date', '__return_false' );
-I've added the code both ways with a custom function and without, in my child themes funtions.php folder...Nothing.
Anything else I should try would love to get this working, as it's kinda a convent feature to have when events aren't in the current month.
I have been using this filter to set the calendar to show the first available date using version 1.16 of WooCommerce bookings. I recently updated to the latest version 2.0.3 and this no longer works. I have rolled the plugin version back and it starts working correctly again.
@liammcluckie I do no directly control the code for the Bookings plugin, if you are having an issue with it, I would recommend reaching out to support at WooCommerce.com.
For what it's worth, I did check Bookings and the filter still exists, so if it's not working support should be notified.
@jessepearson Thanks for the reply. Apologies for adding this here, for some reason I thought this thread was part of the plugin repo! I will get a ticket open with support. Cheers
I have the same problem here, after 2 years of usage. Very odd.
@tfrank77 Just to let you know I have contacted WooCommerce support and they have replicated the bug. Their developers have been notified and are working on a fix. They have recommended rolling back to the previous version until this is patched
Just to let you know I have contacted WooCommerce
Brilliant news, thank you @liammcluckie.
From woo: The filter was working on version 2.0.2 and stopped working when version 2.0.3 was released. Support sent me version 2.0.2 not sure if there is an official download source for old versions.
@fscriven You can reach out to Woo support for a copy of the older version. They have an issue open for the bug, the issue number is 3695.
Thanks guys for the info!
This is not working in my case, I have it on a duplicate site with all other plugins disabled and the 2017 theme and still doesn't work, only tested on mac but all three browsers exhibit the same behavior, always shows the current month, plus the default min lead time. It used to work then a bookings plugin update ruined it, support hasn't been able to help yet. Digging into the code and forcing the state this filter invokes does nothing as well. Just wanted to let people know it might not always work, if at all.