title: Modify WooCommerce Is_Purchasable
body: <p>I was working on implementing my own pre-order system, where I set a <code>is_preorder</code> custom field for each product.</p>
  
  <p>I was trying to modify the WooCommerce's <code>Is_Purchasable</code> option so that, if the product has pre-order status <strong>and</strong> it's already passed the pre-order deadline, it shouldn't be able to be purchased. I've tried a bunch of ways, but nothing seems working.</p>
  
  <p>Here's something that I did (rough idea)</p>
  
  <pre><code>add_filter('woocommerce_is_purchasable', 'preorder_is_purchasable');
  
  function preorder_is_purchasable() {
  
      // this is a field added using 'Advance Custom Fields' plugin 
      $is_preorder = get_field('is_preorder'); 
  
      if($is_preorder &amp;&amp; "not yet passed deadline")
          return true;
      else
          return false;
  }
  </code></pre>
  
  <p>I don't just wanna disable the <code>add_to_cart</code> button, I also want to disable the functionality (should prompt error if user tried to add product by hardcoding in url).<br>
  How should I go on with this?</p>
  
  <p>===========================================================================</p>
  
  <p>Here's my final code:</p>
  
  <pre><code>add_filter('woocommerce_is_purchasable', 'preorder_is_purchasable', 10, 2);
  
  function preorder_is_purchasable( $is_purchasable, $object ) {
  
  // this is a field added using 'Advance Custom Fields' plugin 
  $is_preorder = get_field('is_preorder', $object-&gt;id); 
  
  // if product is Pre-Order
  if($is_preorder)
  {
      $today = date('Ymd');
  
      // another field added using 'Advance Custom Fields' plugin 
      $preorder_deadline = get_field('preorder_deadline', $object-&gt;id); 
  
      if($today &lt;= $preorder_deadline) // if not yet pass deadline
          return true;
      else
          return false;
  }
  else
      return $is_purchasable; // normal
  </code></pre>