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.
AND THERE APPEARS TO BE NO WAY TO CREATE OBJECTS IN LIQUID. CREATING ARRAYS IS A UGLY HACK AS IS:
{% 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 %}
https://ellodave.dev/blog/article/advanced-liquid-arrays/
https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers
Eagerly awaiting a response for how to modify liquid templates to hide out of stock items WITHOUT messing up pagination.