title: Adding New Stock Status to Products in Woocommerce
body: <p>I'm trying to add a new "Sold" Status to products in Woocommerce.
  I have already found many solutions but non of them handles the Sold as an out of stock.</p>
  
  <p>The sold products are also out of stock but they will never return back in stock again.</p>
  
  <p>All solutions I found will set the "sold" status as either "available on back order" or "in stock". but I need it to be handled by Woocommerce like an "out of stock" product.</p>
  
  <p>Here is my recent attempt.</p>
  
  <pre><code>function add_custom_stock_type() { ?&gt;
  &lt;script type="text/javascript"&gt;
      jQuery(function(){
          jQuery('._stock_status_field').not('.custom-stock-status').remove();
      });
  &lt;/script&gt;
  
  
  &lt;?php   
  
  woocommerce_wp_select( array( 'id' =&gt; '_stock_status', 'wrapper_class' =&gt; 'hide_if_variable custom-stock-status', 'label' =&gt; __( 'Stock status', 'woocommerce' ), 'options' =&gt; array(
      'instock' =&gt; __( 'In stock', 'woocommerce' ),
      'outofstock' =&gt; __( 'Out of stock', 'woocommerce' ),
      'available_on_backorder' =&gt; __('On Backorder', 'woocommerce' ),
      'sold' =&gt; __( 'Sold', 'woocommerce' ), // New
  ), 'desc_tip' =&gt; true, 'description' =&gt; __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ) ) );
  
  }
  add_action('woocommerce_product_options_stock_status', 'add_custom_stock_type');
  
  
  function save_custom_stock_status( $product_id ) {
  update_post_meta( $product_id, '_stock_status', wc_clean( $_POST['_stock_status'] ) );
  }
  
  add_action('woocommerce_process_product_meta', 'save_custom_stock_status',99,1);
  
  
  function woocommerce_get_custom_availability( $data, $product ) {
  $stock_status = get_post_meta($product-&gt;id , '_stock_status' , true );
  switch( $stock_status  ) {
      case 'sold':
          $data = array( 'availability' =&gt; __( 'Sold', 'woocommerce' ), 'class' =&gt; 'out-of-stock' );
      break;
      case 'instock':
          $data = array( 'availability' =&gt; __( 'In stock', 'woocommerce' ), 'class' =&gt; 'in-stock' );
      break;
      case 'onbackorder':
          $data = array( 'availability' =&gt; __( 'On Backorder', 'woocommerce'), 'class' =&gt; 'available-on-backorder');
      break;  
      case 'outofstock':
          $data = array( 'availability' =&gt; __( 'Out of stock', 'woocommerce' ), 'class' =&gt; 'out-of-stock' );
      break;
  }
  return $data;
  }
  add_action('woocommerce_get_availability', 'woocommerce_get_custom_availability', 10,4);
  </code></pre>
  
  <p>I also noticed that changing the two integer parameters in</p>
  
  <pre><code>add_action('woocommerce_get_availability', 'woocommerce_get_custom_availability', 10,4);
  </code></pre>
  
  <p>will mostly change the status between (available on backorder) and in stock.</p>