Updates, tips and notes on design and code
Looking for Shopify Code Snippets? See my GitHub Repo
When wanting to view Shopify collections with varied amounts of products per page (aka, pagination) the usual method involves creating a series of alternate templates. Let's explore an idea that ditches the multiples, and just uses one.
Every now and again I see merchants creating alternate templates in their account that actually breaks some common Shopify code. The code assumes that if a template name contains the word 'product' that it must be a product template - that's not always the case.
The cycle Liquid filter is useful when you need to output a series of known string parameters in a sequential order loop. One thing cycle doesn't do is give you the ability to use dynamic amounts of assigned variable data - let's look at a quick way to do something just like it.
There's going to be times when you want to show a list of the most recents articles (posts) from all your Shopify Blogs combined - not just pulling the latest ones from a single Blog. Since I saw the question pop up on the ecommerce forums again, I grabbed a vodka and wrote some code.
There's plenty of Shopify ecommerce stores out there that only have a few products, but those products have many variants. The drawback to this approach is that collection pages can look a little sparse but let's fix that with some simple theme edits.
If you must check if something is a number within liquid there’s neat little trick you can use with the existing json filter. The filter has it’s own datatype check in place so it knows whether to wrap the value in quotes of not.