title: Restrict delivery dates for some specific product categories in Woocommerce
body: <p>I've added DatePicker to my checkout page for customers to pick the delivery date. Also added a script to disable past dates (obviously) and delivery on some holidays. </p>
  
  <p>Here is the script:</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script&gt;
  var disableddates = ["14-02-2018", "25-12-2018"];
  
  function DisableSpecificDates(date) {
      var string = jQuery.datepicker.formatDate("dd-mm-yy", date);
      return [disableddates.indexOf(string) == -1];
  }
  
  jQuery(function() {
      jQuery("#billing_delivery_date").datepicker({
          dateFormat: "DD, d MM, yy",
          beforeShowDay: DisableSpecificDates,
          minDate: new Date()
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>And it works perfectly until I try to put some restrictions on it. I need just disable holiday delivery for some categories, not for all. I did it like that:</p>
  
  <pre><code>function add_checkout_script() {
      foreach ( WC()-&gt;cart-&gt;get_cart() as $cart_item_key =&gt; $cart_item ) {    
          // if a product is not in our cat, bail out since we know the cat is not alone
          if ( has_term( my_category, 'product_cat', $cart_item['data']-&gt;id ) ) {
              wp_enqueue_script( 'newscript', get_stylesheet_directory_uri() . '/restrict_day_script.js', array( 'jquery' ));
          }
      }   
  } 
  add_action( 'woocommerce_after_checkout_form', 'add_checkout_script' );
  </code></pre>
  
  <p>Also tried just paste the script:</p>
  
  <pre><code>function add_checkout_script() {
      foreach ( WC()-&gt;cart-&gt;get_cart() as $cart_item_key =&gt; $cart_item ) {    
          // if a product is not in our cat, bail out since we know the cat is not alone
          if ( has_term( my_category, 'product_cat', $cart_item['data']-&gt;id ) ) {
              ?&gt;
              &lt;script&gt;
              var disableddates = ["14-02-2018", "25-12-2018"];
  
              function DisableSpecificDates(date) {
                  var string = jQuery.datepicker.formatDate("dd-mm-yy", date);
                  return [disableddates.indexOf(string) == -1];
              }
  
              jQuery(function() {
                  jQuery("#billing_delivery_date").datepicker({
                      dateFormat: "DD, d MM, yy",
                      beforeShowDay: DisableSpecificDates,
                      minDate: new Date()
                  });
              });
              &lt;/script&gt;
              &lt;?php
          }
      }    
  }
  add_action( 'woocommerce_after_checkout_form', 'add_checkout_script' );
  </code></pre>
  
  <p>What am I doing wrong?</p>