Last active
September 25, 2025 07:44
-
-
Save UraraReika/0a4963ccba2bb4e0f922211e26b03ef6 to your computer and use it in GitHub Desktop.
Add buffer days after booking in JetBooking plugin in date picker field. Works with plain and Woo modes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.addEventListener( 'DOMContentLoaded', function() { | |
| // You can edit this variable. | |
| const buffer = 4; // Number of days to be disabled as buffer; | |
| // You can edit this variable. | |
| const isBufferDay = ( day ) => { | |
| if ( JetABAFData.booked_dates.includes( day.format( 'YYYY-MM-DD' ) ) ) { | |
| return false; | |
| } | |
| for ( let i = 1; i <= buffer; i++ ) { | |
| const bufferDay = day.clone().subtract( i, 'day' ).format( 'YYYY-MM-DD' ); | |
| if ( JetABAFData.booked_dates.includes( bufferDay ) ) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| if ( ! window.JetPlugins ) return; | |
| window.JetPlugins.hooks.addFilter( 'jet-booking.input.config', 'jetBooking', ( config ) => { | |
| const validateDay = config.beforeShowDay; | |
| config.beforeShowDay = function ( t ) { | |
| if ( isBufferDay( moment( t ) ) ) { | |
| return [ false, 'maintenance', 'Preparation day' ]; | |
| } | |
| return validateDay( t ); | |
| }; | |
| return config; | |
| } ); | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment