<?php

use Dreamfox\DeliveryDate\Helpers\DateHelper;

  $checkout = WC()->checkout();
  if (!array_key_exists(DREAMFOX_WDD_FIELD_NAME, $checkout->checkout_fields)) {
    return false;
  }
?>
<div class="dreamfox-delivery-date" id="dd__checkout_field">
  <h3><?php esc_html_e( 'Delivery Info', 'woocommerce-delivery-date' ); ?></h3>
    <?php foreach ($checkout->checkout_fields[DREAMFOX_WDD_FIELD_NAME] as $key => $field) : ?>
      <?php woocommerce_form_field($key, $field, $checkout->get_value($key)); ?>
    <?php endforeach; ?>
</div>

<script>
jQuery(function($) {
    $('#<?php echo esc_js( DREAMFOX_WDD_FIELD_NAME ); ?>').datepicker({
        dateFormat: <?php echo wp_json_encode( DateHelper::getJsDateFormat( get_option( 'date_format' ) ) ); ?>,
        minDate: <?php echo (int) $this->getMinDate(); ?>,
    });
});
</script>
