Sometimes shops have to deal with a lot of “sold” products and the products table becomes messy, so this is a way to sort by stock status (In stock -> Out of stock) on load. You can then use the column headers to sort by other data as usual, so this will only work once you access /wp-admin/edit.php?post_type=product page.
So, here’s a very simple snippet for you. Enjoy!
PHP Snippet: Sort Products by Stock Status @ WooCommerce Admin
This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101
Related content
WooCommerce: Add Second Description @ Product Category Pages In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
WooCommerce: Display “In Stock” Products First @ Shop We’ve already seen how to add a custom “Product Sorting” option to the “Default Sorting” dropdown in the WooCommerce Shop page. The task I was presented with, however, was to display items based on a custom “meta key”. Now, if you have no idea what a “meta key” is, don’t worry too much. For example, […]
WooCommerce: Add Column to Orders Table @ WP Dashboard The WooCommerce Orders Table, which can be found under WP Dashboard > WooCommerce > Orders, provides us with 7 default columns: Order – Date – Status – Billing – Ship to – Total – Actions. This is used by shop managers to have an overview of all orders, before eventually clicking on a specific one. […]
WooCommerce: Display Custom Filters @ WP Dashboard > Products If you go to WordPress Dashboard > Products you will find default product admin filters such as “Select a category”, “Filter by product type”, “Filter by stock status”. What if you want to add more custom filters to let your shop managers find products easily? For example, you could add “Filter by product tag” (“product […]
WooCommerce: Hide/Show The WP Admin Bar In previous WooCommerce versions, new customers could access the WP Admin black bar after purchase. Now this seems fixed. Still, what about other user roles, and what if you want to override this default behavior? Well, here’s a quick snippet for you – feel free to use it in your own WooCommerce site. Enjoy!
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli
2 thoughts on “WooCommerce: Sort Products By Stock @ Admin Dashboard”
Hello,
The code works but it does not short the products correctly from Product with most stock to product with least stock.
As of now it shows product in stock first organized randomly (no matter the quantity in stock) and then out of stock items.
How could I get the product in stock organized by stock quantity most quantity to least quantity?
Many thanks
Federico
Questions? Feedback? Customization? Leave your comment now! _____
If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!
Hello,
The code works but it does not short the products correctly from Product with most stock to product with least stock.
As of now it shows product in stock first organized randomly (no matter the quantity in stock) and then out of stock items.
How could I get the product in stock organized by stock quantity most quantity to least quantity?
Many thanks
Federico
Hello Federico, you could use an array inside the “orderby” setting: https://make.wordpress.org/core/2014/08/29/a-more-powerful-order-by-in-wordpress-4-0/