Skip to content

Instantly share code, notes, and snippets.

@woogists
Created March 9, 2018 16:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woogists/763bcc49e7316dd80131e08cd09e6752 to your computer and use it in GitHub Desktop.
Save woogists/763bcc49e7316dd80131e08cd09e6752 to your computer and use it in GitHub Desktop.
[Checkout field editor] Adjust the datepicker in the Checkout Field Editor plugin.
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 );
@markdh1
Copy link

markdh1 commented Feb 10, 2020

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. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment