WooCommerce allows product sorting by the default criteria:
- Sort by popularity
- Sort by average rating
- Sort by latest
- Sort by price: low to high
- Sort by price: high to low
Unfortunately, in both cases the “in stock” and “out of stock” products are mixed together. A more UX-friendly approach will be to first show “in stock” products. To achieve this, it’s necessary to first apply “stock status” sorting and then sorting eg. “by latest”.
FiboFilters has a built-in solution that lets you prioritize the “in stock” status and display such products first.
The feature is disabled by default. To turn it on, add this PHP snippet to your functions.php in a child theme.
add_filter('fibofilters/request/base_product_ids/order_by_stock_status', '__return_true');
As a result, users should see “in-stock” products first, then “out-of-stock” products as in the screenshot below.