How can I prioritize sorting In Stock products first and Out of Stock Items last in collections?

How can I prioritize sorting In Stock products first and Out of Stock Items last in collections?

CMET
Shopify Partner
4 1 3

How can I prioritize sorting In Stock products first and Out of Stock Items last in collections, without using a third-party app?

 

I’m trying to achieve this through custom coding in Liquid. I’ve successfully created two different arrays for products in stock and out of stock. However, when I render these arrays on Shopify, they only sort within the same page.

 

For instance, on page 3, the top of the page is filled with In Stock items, while the bottom is filled with Out of Stock items. This pattern repeats on pages 4, 5, and all others. Essentially, Shopify only sorts within the same page.

 

As far as I understand, Shopify doesn’t allow paginating modified arrays. Has anyone been able to figure out a solution to this sorting type?

Replies 2 (2)

Guleria
Shopify Partner
3992 795 1134

Hello @CMET ,

 

Yes you are right this thing is possible with pagination. btw if you still need this the only possible way is lode more concept, where every time you need to insert the in stock product before out of stock using Javascript.

 

Regards

Guleria
 

- Custom themes, UI/UX design, ongoing maintenance & support.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder

PaulNewton
Shopify Partner
7721 678 1619

Hi @CMET research prior topics on custom sorting in liquid, with/without "algorithm" , TQ&A subforum tends to be better.

without using a third-party app it breaks down to:

  • give every collection 2 additional smart collections , 1 for stocked 1 for out of stock then join them with pagination offset on the frontend; can be the sanest for multi-channel scenarios.
  • or if a manual collection use shopify-flow to hypothetically sort the manual collection
  • or wrap a loop in pagination and set a high item count ~250~1k then try to parse everything into a specific sort; research prior topics
  • Do the sort on the frontend with javascript by preloading as much collection|product data as much as possible|reasonable.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org