Skip to content

Instantly share code, notes, and snippets.

@sardbaba
Forked from kloon/functions.php
Last active December 4, 2015 17:59
Show Gist options
  • Save sardbaba/143ff99ed5e253570440 to your computer and use it in GitHub Desktop.
Save sardbaba/143ff99ed5e253570440 to your computer and use it in GitHub Desktop.
<?php
// Add a date range to a datepicker field, replace #date with the id of the date field.
add_filter( 'wp_footer' , 'woo_add_checkout_field_date_range_limit' );
function woo_add_checkout_field_date_range_limit() {
if ( is_checkout() ) {
$js = 'jQuery( "#date" ).datepicker({ minDate: -5, maxDate: "+1M +10D" });';
// Check if WC 2.1+
if ( defined( 'WC_VERSION' ) && WC_VERSION ) {
wc_enqueue_js( $js );
} else {
global $woocommerce;
$woocommerce->add_inline_js( $js );
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment