"i only speak liquid" #35: Re-orderable Metaobjects

Written by Billy (a Storetasker Expert)

Hey all 👋!

Welcome to 'i_only_speak_liquid' by Storetasker, where active Shopify developers like me (Billy) share the learnings we face daily. This is my 7th edition of ‘i_only_speak_liquid’. Enjoy!

What I’ve been thinking about:

Recently, I have been working on a custom collection page which required the client to be able to create a list of filters, the main label for these filters and also control the order.

Usually this could have been controlled through something like a comma separated list as a theme setting, for example:

colours:shopify_colours, category:shopify_product_type, size:shopify_size, price: shopify_price

Whilst this method definitely meets all of the requirements needed by the client and would allow me to build the filters in Liquid, it is not the most client friendly or very manageable. If the client accidentally forgets to use a comma or does not add the label before the filter, it starts to break the code.

Since Metaobjects have been released by Shopify, I am constantly finding out about the many use cases for them and how powerful they really are. I have since stopped using lists like the comma separated one above and have made the switch to using Metaobjects instead.

One issue that I have had is how you can reorder Metaobject entries and give the client control over the order. I’ve recently been shown a really good way of handling this and definitely think it will be useful for many other developers.

You start by creating a new Metaobject, this will be used for the individual entries, for example this will be for the actual filter itself - for my specific usecase all I needed was the label and the value.

You then create another new Metaobject, which will be used for the list and can be achieved by adding a field with the type Metaobject and choosing ‘List of entries’. This will allow you to then add all of your filters to the filter list and the client can reorder them as needed.

One issue I have found with Metaobjects is that sometimes specific types can result in confusing code, it can also be difficult to loop through certain pieces of data and return the code in JSON format.

Below you can see how I was able to loop through the Filter List and create a global variable that I can then use within my Javascript code to access all of the set filter labels and values by the client.

3 links you can’t miss:

  • DTC Leaders: A neat resource by Storetasker which highlights some of the best people in the small community of eCommerce.

  • Nearest Aspect Ratio Calculator: I’m often working from designs and need to make sure an image matches the aspect-ratio, however sometimes you can have issues finding the closest correct aspect-ratio. This is a really handy calculator that does exactly what it is called.

  • Godly Website: I am always checking this website and using it as a source of inspiration for some of the best designed websites. This is definitely a website to keep bookmarked.I am always checking this website and using it as a source of inspiration for some of the best designed websites. This is definitely a website to keep bookmarked.

One app I like:

I have used Nosto quite a few times on different projects and have been able to take advantage of the powerful product recommendations it offers. Whether you need category metchandising based on shopper behaviour, product bundles, the ability to segment your shoppers based on their actions, or personalise content based on that individual user. The app provides a whole host of extremely powerful features - It even has the ability to A/B test to improve product recommendations and conversions.

One learning as a freelancer:

When you first get started as a freelancer, it can be really hard to believe in yourself and truly see the value that you can provide. Whilst this is definitely something that does come with time and experience, I definitely think it’s an issue we can all run into from time to time and suffer from imposter syndrome.

One thing I have learnt is to be confident with the work you produce, clients are often coming to you because of the great projects they have seen of yours online and usually have a lot more belief in you, than you may have even in yourself.

Over time you will start to see the expertise you offer, become more confident and this will in-turn generate more leads.

Billy (linkedin)