Skip to content

Instantly share code, notes, and snippets.

@bhavik-kiri
Last active November 30, 2017 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhavik-kiri/10e44ea2318c567c4060767b70ed4e1e to your computer and use it in GitHub Desktop.
Save bhavik-kiri/10e44ea2318c567c4060767b70ed4e1e to your computer and use it in GitHub Desktop.
<?php
add_action( 'woocommerce_after_checkout_billing_form', 'display_extra_fields_after_billing_address' , 10, 1 );
function display_extra_fields_after_billing_address () {
_e( "Delivery Date: ", "add_extra_fields");
?>
<br>
<input type="text" name="add_delivery_date" class="add_delivery_date" placeholder="Delivery Date">
<script>
jQuery(document).ready(function( $ ) {
$( ".add_delivery_date").datepicker( {
minDate: 0,
} );
} );
</script>
<?php
}
add_action( 'wp_enqueue_scripts', 'enqueue_datepicker' );
function enqueue_datepicker() {
if ( is_checkout() ) {
// Load the datepicker script (pre-registered in WordPress).
wp_enqueue_script( 'jquery-ui-datepicker' );
// You need styling for the datepicker. For simplicity I've linked to Google's hosted jQuery UI CSS.
wp_register_style( 'jquery-ui', '//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css' );
wp_enqueue_style( 'jquery-ui' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment