Title: Adding stock option
Last modified: October 12, 2016

---

# Adding stock option

 *  [Trinitech](https://wordpress.org/support/users/trinitech/)
 * (@trinitech)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-stock-option/)
 * Hi,
 * I have managed to create a new stock option called ‘Available to Order’ but when
   I select it, the add to cart button is not displaying…
    Could anyone please help
   me spot the issue?
 * Thank you
 *     ```
       /*adding stock option*/
   
       function add_custom_stock_type() {
           ?>
           <script type="text/javascript">
           jQuery(function(){
               jQuery('._stock_status_field').not('.custom-stock-status').remove();
           });
           </script>
           <?php   
   
           woocommerce_wp_select( array( 'id' => '_stock_status', 'wrapper_class' => 'hide_if_variable custom-stock-status', 'label' => __( 'Stock status', 'woocommerce' ), 'options' => array(
               'instock' => __( 'In stock', 'woocommerce' ),
               'outofstock' => __( 'Out of stock', 'woocommerce' ),
               'onrequest' => __( 'Available to Order', 'woocommerce' ), // The new option !!!
           ), 'desc_tip' => true, 'description' => __( '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 ) {
           switch( $product->stock_status ) {
               case 'instock':
                   $data = array( 'availability' => __( 'In stock', 'woocommerce' ), 'class' => 'in-stock' );
               break;
               case 'outofstock':
                   $data = array( 'availability' => __( 'Out of stock', 'woocommerce' ), 'class' => 'out-of-stock' );
               break;
               case 'onrequest':
                   $data = array( 'availability' => __( 'Available to Order', 'woocommerce' ), 'class' => 'on-request' );
               break;
           }
           return $data;
       }
       add_action('woocommerce_get_availability', 'woocommerce_get_custom_availability', 10, 2);
       ```
   

The topic ‘Adding stock option’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Trinitech](https://wordpress.org/support/users/trinitech/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/adding-stock-option/)
 * Status: not resolved