title: WooCommerce product categories custom fields - Setting time purchasing restrictions
body: <p>I have a Wordpress/WooCommerce site that displays categorized products. I'm trying to create a custom field in Admin individual categories pages (backend), where I can set a <strong>start</strong> and <strong>end</strong> <strong>time</strong> related to categorized products purchase availability. </p>
  
  <p><strong>How this should work:</strong><br>
  The customers could only purchase products which category is "open" (between the start and end time set to this category) but all products will still visible even if they are not purchasable.</p>
  
  <p>I was wondering if someone has an idea about the best way to begin and achieve that.</p>
  
  <p>For the moment here is the related code that I have:</p>
  
  <pre><code>function custom_product_taxonomy_add_new_meta_field() { //add term page
  //this will add the custom meta field to the add new term page
    ?&gt;
    &lt;div class="form-field"&gt;
      &lt;label for="term_meta[custom_term_meta]"&gt;&lt;?php _e( 'Post Code(s)' ); ?&gt;&lt;/label&gt;
      &lt;input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value=""&gt;
      &lt;p class="description"&gt;&lt;?php _e( 'Enter the delivery post codes available for this store.','my-text-domain' ); ?&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;?php
  }
  add_action( 'product_cat_add_form_fields', 'custom_product_taxonomy_add_new_meta_field', 10, 2 );
  //edit term page
  function custom_product_taxonomy_edit_meta_field($term) {
  //put the term ID into a variable
    $t_id = $term-&gt;term_id;
    //retrieve the existing value(s) for this meta field. This returns an array
    $term_meta = get_option( "taxonomy_$t_id" ); ?&gt;
    &lt;tr class="form-field"&gt;
    &lt;th scope="row" valign="top"&gt;&lt;label for="term_meta[custom_term_meta]"&gt;&lt;?php _e( 'Post Code(s)' ); ?&gt;&lt;/label&gt;&lt;/th&gt;
      &lt;td&gt;
        &lt;input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="&lt;?php echo esc_attr( $term_meta['custom_term_meta'] ) ? esc_attr( $term_meta['custom_term_meta'] ) : ''; ?&gt;"&gt;
        &lt;p class="description"&gt;&lt;?php _e( 'Enter the delivery post codes available for this store.' ); ?&gt;&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;?php
  }
  add_action( 'product_cat_edit_form_fields', 'custom_product_taxonomy_edit_meta_field', 10, 2 );
  //save extra taxonomy fields callback function.
  function save_taxonomy_custom_meta( $term_id ) {
    if ( isset( $_POST['term_meta'] ) ) {
        $t_id = $term_id;
        $term_meta = get_option( "taxonomy_$t_id" );
        $cat_keys = array_keys( $_POST['term_meta'] );
        foreach ( $cat_keys as $key ) {
            if ( isset ( $_POST['term_meta'][$key] ) ) {
                $term_meta[$key] = $_POST['term_meta'][$key];
            }
        }
        update_option( "taxonomy_$t_id", $term_meta ); //save the option array.
    }
  }
  add_action( 'edited_product_cat', 'save_taxonomy_custom_meta', 10, 2 );
  add_action( 'create_product_cat', 'save_taxonomy_custom_meta', 10, 2 );
  </code></pre>
  
  <p>This code adds a custom field in Admin categories pages, but like I have said before, I am looking for a custom field where I can set a starting and ending time.</p>
  
  <p>Please any suggestions are welcome, as I've been on this for weeks and just looking for solutions. </p>
  
  <p>Thanks in advance.</p>