How to move out-of-stock products to the end of collection without using an app

Hi everyone,

I want to display out-of-stock products at the end of my collection page.

Currently, we are using an app/plugin to push sold-out items to the bottom, but I would like to achieve this without any app, using Shopify’s default features or theme customization.

My requirement:

  • In-stock products should appear first

  • Sold-out products should automatically move to the bottom

  • This should work dynamically when stock changes

My store details:

  • Collection link: V Neck Kurti

  • Theme name: Minimalista

  • Inventory tracking is enabled

I checked collection sorting options but didn’t find a way to sort based on stock status. Is there any Liquid code, setting, or workaround to do this natively?

Thanks in advance!

No.
This cannot be done in liquid and needs to be done in back-end and only for “manual” sort option by re-sorting products in collection.
When changing sort order in front-end sold products will be re-positioned according to the new sort order.

Potentially, it should be possible to achieve with free Shopify app Flow, but there is a bunch of paid apps to do that, some may be not expensive.

Hi @Aarni

Yes, this is possible, but it requires custom code.
By modifying the collection template (Liquid), we can:

Display in-stock products first
Move out-of-stock products to the bottom
Have it update automatically when inventory changes

Best regards,
Devcoder :laptop:

Hi @Aarni ,

Agree with @devcoders , it can be done but it does require modifying your collection template.

The July clarification is important: Liquid/JS cannot give a correct whole-collection result once pagination is involved.

If you want this dynamic and accurate across the full collection, keep the collection on manual order and have an inventory-triggered Admin API job calculate an explicit ranking. One important guardrail: do not treat “quantity 0” as an automatic push-down. Keep pre-order / Continue selling products separate, and only demote products that have no sellable variant.

Before writing the job, I would export the product data and review:

  • fully unavailable products vs products with at least one sellable variant
  • whether a sold-out product is deliberately a prominent pre-order item
  • which manual collection positions must be protected

That gives you a small, safe action list instead of a reordering script that later demotes products you still want to sell.

I’m testing a read-only CSV collection check for exactly this preflight (no Shopify login or changes). Happy to run it free if you want the action list.