Re: Your developers need to make it easier to hide out of stock items! How to edit my liquid templat

Your developers need to make it easier to hide out of stock items! How to edit my liquid template?

6 0 1

Hi I'm an aging web developer. All I want is the option to hide out of stock items site/theme wide.


Having todo this on a per collection basis sucks because:

I have over 50 collections.

I can only use AND or OR for ALL RULES.

So I can do it per collection with AND conditions but this limits how catch all I can make my conditions and

requires more consistent carefullness from the person entering the item data.


Having to install some convoluted app todo this is insane. Can I write a custom app that creates and exposes a ruby filter my code can use while on the $29/month plan?


I thought I'd simply alter the liquid templates todo this and noticed that IS NOT POSSIBLE afaik!

Really learned how limited liquid is today... which removes a lot of utility from your platform!


Liquid your custom html template language (probably written in ruby?) doesn't really support basic programming features like removing an element from an array or collection or custom products object. Creating a new array with only some of the elements from the products collection also doesn't work because it's not an object paginate likes.


It's a decent compromise if this is a "unexposed" feature like making pagination part of the liquid language BUT THAN WHERE IS MY SIMPLE CHECKBOX IS SETTINGS to hide out of stock items with 1 click?


I refuse to pay $79/per month to use the script editor app which MIGHT allow me to write a custom filter function in ruby to use in my liquid templates. And I can't see how else I can do this without breaking pagination...

Please do enlighten me if I am missing anything? Please have someone who knows liquid and works for spotify support, either tell me what I'm missing or confirm this IS NOT POSSIBLE in liquid without a custom ruby filter function?


Because liquid has built in pagination, I need to alter the contents of collection.products BEFORE 

{% paginate collection.products by 12 %} happens in collection-template.liquid


You could just add a built in filter which filters the the contents of collection.products to in stock items....


I tried to create a new data structure like this, BUT it doesn't have the properties paginate expects.


{% assign inStockProducts = null | sort %}
{% for product in collection.products %}
{% if product.selected_or_first_available_variant.available <= 0 %}
{% assign inStockProduct = product | sort %} {% assign inStockProducts = inStockProducts | concat: inStockProduct %}
{% endif %}
{% endfor %}


Eagerly awaiting a response for how to modify liquid templates to hide out of stock items WITHOUT messing up pagination.

Replies 5 (5)

Shopify Partner
110 10 23

Hello @hudlee 
I think you need to make some adjustments to your product loop in the collection pages 
See this solution given by Shopify

Please note it will filter the items that are completely out of stock. If an item has a single variant available then it won't filter it. 

- Did you find my response useful? Mark it as "Accepted solution"; so others can see it, or just like it.
- VTN Checkout Plus Looking for a Checkout App for your store? Check this app for all Shopify Plans.
- Feel free to Contact me
6 0 1

You are suggesting I use the built-in where filter, with only a string key and no value. When not giving a value it checks if something is true which can shoehorn qty >= 1 (as 0 or -1 would evaluate to false. That part sounds ok, BUT IT DOES NOT WORK FOR 2 OTHER REASONS:


{% assign inStockProducts = collections.products %}
{% paginate inStockProducts by 15 %}


This results in Liquid error (sections/collection-template line 5): Array 'inStockProducts' is not paginateable.


And in the example in

The data in only 1 property deep, I need to access 2 levels of nesting deep: 



When I do this:


{% assign inStockProducts = collections.products | where: "selected_or_first_available_variant.available" %}
{% for product in inStockProducts %}
    qty: {{ product.selected_or_first_available_variant.available }}<br> 
{% endfor %}


I noticed the where filter is producing an empty array. | where: 'available' is also not the qty property I am looking for.

Even if there is a 1 layer deep property I'm missing, even if I have the nested prop syntax wrong, this still won't solve the pagination issue.


Does shopify want me to not use their pagination code and load EVERYTHING? or roll my own with javascript... ick.

Don't seem to have direct control of the url routing system to write my own server side pagination...


How do I "inspect" collections.product to see all the properties and values?


6 0 1



Splits an array's items across multiple pages.

Because for loops are limited to 50 iterations per page, you need to use the paginate tag to iterate over an array that has more than 50 items. The following arrays can be paginated:

Would someone with access to the underlying ruby code please let me know what makes an array  work with liquids paginated tag?

Can i use a metavalue to make a custom object that can be paginated?

Shopify Admin -> Settings -> Custom Data -> Products -> Add Definition....


To many esoteric dead end possibilities!

The shopify devs either need to add a built-in filter that hides out of stock items in a collection. 


give me the ability to execute ruby in a limited way to create a custom data object I can pass to my liquid template.


I'm going to escalate this until you either prove me wrong or admit this shortcumming.

Hiding out of stock products should be a basic feature on all plans!

6 0 1

The fact that this page lists app after app that charges monthly fees to accomplish this is a disgrace!

3 0 0

Hey @hudlee I feel your frustration. I ran across your post which I hoped would have answers and it did not so I kept looking and finally found an app that worked for me. I am just starting out so I don't have a lot going on, but this Wipeout app was free and worked for me. It lets you do up to 3000 products and it is manual, but they made it real easy with basically click a button and out of stock goes away. Supposedly when it comes back in stock you can go click a button to get them back in stock.

Fallen Star