Updates, tips and notes on design and code
Looking for Shopify Code Snippets? See my GitHub Repo
Shopify recently dropped a feature that allows discount codes to be shared in a url - aptly called Shareable Discount Links. I had a few people ping me on how they can access the actual code used one the storefront so let's talk about it.
Shopify Gift Card images are something you can customise but it's not as simple to show the actual variant image on the page the customer sees. Let's look at some code to let you show the variant image in the Gift Card template.
Shopify allows you to dynamically adjust the order of a collection using the sort_by querystring in the url. Let's explore some simple code that makes it harder for a customer to use that sorting querystring to see your best sellers.
The fun thing about the undocumented sort_by property on collections is that you can pass whatever string to it that you like, and then be able to use it in Liquid. It's a pretty gross hack, but it might come in handy one day.
The need to schedule content changes in Shopify is something that apps are great at since the API gives many options for changes in content, and theme. Now if you're feeling a little DIY and want to build in something without an app there is way - let's explore it.
Generally a hidden collection won't be accessible in Liquid, but it is when referenced via a menu (linklist). It's important that your code can handle this possibility and skips the hidden collection in your loop - let's look at the simple code to do it.
Shopify Liquid has allows you to change the formatting of the date string but the default output is English. If you want to change the days or months to be shown in another language you'll need to translate it.