Created
March 9, 2018 16:27
-
-
Save woogists/763bcc49e7316dd80131e08cd09e6752 to your computer and use it in GitHub Desktop.
[Checkout field editor] Adjust the datepicker in the Checkout Field Editor plugin.
This file contains 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
function custom_adjust_datepicker_range () { | |
if ( is_checkout() ) { | |
wp_enqueue_script( 'jquery' ); | |
?> | |
<script type="text/javascript"> | |
jQuery( document ).ready( function ( e ) { | |
if ( jQuery( '.checkout-date-picker' ).length ) { | |
jQuery( '.checkout-date-picker' ).datepicker( 'option', 'changeYear', true ); | |
jQuery( '.checkout-date-picker' ).datepicker( 'option', 'yearRange', '-40:+0' ); | |
} | |
}); | |
</script> | |
<?php | |
} | |
} // End custom_adjust_datepicker_range() | |
add_action( 'wp_footer', 'custom_adjust_datepicker_range', 50 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to use a similar filter to only allow dates 2 days from todays date to be selected. Example would be using this for a delivery preference date selection and giving some lead time. Don't want them selecting today's date for it to be delivered. :-)