Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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