Title: Sort by availability
Last modified: August 21, 2016

---

# Sort by availability

 *  [Tib781](https://wordpress.org/support/users/tib781/)
 * (@tib781)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/sort-by-availability/)
 * Hello,
 * I try to put a “sort by” products available in my shop but it does not work.
   
   Is that possible? If so how?
 * I can bring up a “sort by availability” in the list but no more.
 * Thank you
 * [http://wordpress.org/extend/plugins/woocommerce/](http://wordpress.org/extend/plugins/woocommerce/)
 * _[[No bumping](http://codex.wordpress.org/Forum_Welcome#No_Bumping). If it’s 
   that urgent, consider [hiring someone](http://jobs.wordpress.net/).]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [IgniteWoo Team](https://wordpress.org/support/users/ignitewoo/)
 * (@ignitewoo)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/sort-by-availability/#post-3659305)
 * What does “Availability” mean to you in this context? Not quite clear on what
   data you want to sort on.
 *  Thread Starter [Tib781](https://wordpress.org/support/users/tib781/)
 * (@tib781)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/sort-by-availability/#post-3659318)
 * I have some product on stock and some another not in stock in each moment.
    So
   I mean with”sort by availability” that my customer can choose to see only the
   products/item in stock in the moment that he look my shop.
 * The “sort by availability” is in the list of all the sorts , but he don’t do 
   the sort, I mean that all the items showing up not only who’s in stock like I
   want to see.
 * Hope you understand and can help me
    thanks thib
 *  [IgniteWoo Team](https://wordpress.org/support/users/ignitewoo/)
 * (@ignitewoo)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/sort-by-availability/#post-3659321)
 * See here:
 * [http://docs.woothemes.com/document/custom-sorting-options-ascdesc/](http://docs.woothemes.com/document/custom-sorting-options-ascdesc/)
 * What you want to do is use that code and add something like this to “case” clauses
   in the custom_woocommerce_get_catalog_ordering_args function:
 *     ```
       case 'availability_asc' :
       	$args['orderby'] = 'meta_value_num';
       	$args['order'] = 'asc';
       	$args['meta_key'] = '_stock';
       break;
       ```
   
 * And something like this to the custom_woocommerce_catalog_orderby function:
 *     ```
       $sortby['availability_asc'] = 'By availability';
       ```
   
 * Or maybe change “asc” to “desc” in all instances. “asc” means ascending ( low
   to high ) , “desc” means decending ( high to low ).
 *  Thread Starter [Tib781](https://wordpress.org/support/users/tib781/)
 * (@tib781)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/sort-by-availability/#post-3659348)
 * I already try this solution but it doesn’t work.
    The “sort by availability” 
   is in the list of all the sorts , but he don’t do the sort.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Sort by availability’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3640790)
 * [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/)

## Tags

 * [by](https://wordpress.org/support/topic-tag/by/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)

 * 4 replies
 * 2 participants
 * Last reply from: [Tib781](https://wordpress.org/support/users/tib781/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/sort-by-availability/#post-3659348)
 * Status: not resolved