Move out-of-stock items to the end of collections.

Topic summary

A merchant with 20,000 products and daily inventory fluctuations (~1,000 items) seeks to automatically move out-of-stock items to the end of collection pages, regardless of sorting or filters applied.

Current Status:

  • Shopify does not offer this as a built-in platform feature
  • Some third-party themes may include this functionality
  • Apps exist on the Shopify App Store that can handle this sorting

Technical Solution Provided:
A community member shared working Liquid code that:

  • Separates products into two arrays using the where filter: available and sold-out items
  • Renders available products first, followed by out-of-stock items
  • Includes specific implementation instructions for Shopify’s Dawn theme (modifying main-collection-product-grid.liquid)

Implementation Considerations:

  • The merchant uses a third-party paid theme (Ocolus), which may require adaptation of the provided code
  • One developer offered paid customization services ($35) to implement the solution
  • The basic logic involves filtering collection.products by the available property and rendering them in two separate loops
Summarized with AI on October 24. AI used: claude-sonnet-4-5-20250929.

I’m using the theme https://themeforest.net/item/ocolus-classic-creative-shopify-theme/46630625?s_rank=2

but I don’t understand what and where to write it correctly?