Skip to content

Instantly share code, notes, and snippets.

View richietyler's full-sized avatar

Richie Tyler richietyler

View GitHub Profile
@richietyler
richietyler / truefit.liquid
Last active August 8, 2024 02:18
Liquid snippet for TrueFit Size Sampling Integration compatible with drawer style carts
{%- if template =='cart' or template contains 'product' -%}
<script>(function(r,e,o){
var w=window,d=document,t,s,x;
w.tfcapi=t=w.tfcapi||function(){t.q=t.q||[]; t.q.push(arguments);};
t('init', {storeKey: r, environment: e, ...o});
x=d.getElementsByTagName('script')[0];
s=d.createElement('script');
s.type='text/javascript';s.async=true;
s.src='https://'+r+'-cdn'+(e==='dev'||e==='staging'?'.'+e:'')+ '.truefitcorp.com/fitrec/'+r+'/js/tf-integration.js';
x.parentNode.insertBefore(s,x);
@richietyler
richietyler / caProvinceCodesToName.js
Created October 28, 2022 00:18
Simple function to convert Canadian province/territory codes to names
function caProvinceCodesToNames(stateCode) {
const code = stateCode.toLowerCase();
if (code === "ab") {
return "Alberta"
} else if (code === "bc") {
return "British Columbia"
} else if (code === "mb") {
return "Manitoba"
} else if (code === "nb") {
return "New Brunswick"
@richietyler
richietyler / usStateCodesToNames.js
Last active February 4, 2022 09:21
USA State codes to State Names function
// Simple function to convert US 2-letter state codes to capitalised state names
function usStateCodesToNames(stateCode) {
const code = stateCode.toLowerCase();
if (code === "al") {
return "Alabama"
} else if (code === "ak") {
return "Alaska"
} else if (code === "az") {
return "Arizona"
{% for opt in product.options_with_values %}
{% if opt.name == 'Size' %}
{% for var in product.variants %}
{% if var.available %}
{% assign spanclass='size-label'%}
{% else %}
{% assign spanclass='size-label size-sold'%}
{% endif %}
{% if opt.values contains var.option1 %}
@richietyler
richietyler / available-sizes.liquid
Last active July 30, 2019 02:05
Display available sizes beneath product on collection page (Shopify). Relies on Dylan Hunt's tutorial on displaying colour variants as separate products (https://dylanjh.com/blogs/15-show-all-colors-of-a-product-as-separate-products-on-the-collection-page)
{% comment %}Print 'colour' variable to show variant loop is working{% endcomment %}
<p><strong>{{ colour }}</strong></p>
{% for product_option in product.options_with_values %}
{% if product_option.name == 'Colour' %}
{% if product_option.values contains colour %}
{% assign proceed = true %}
{% comment %}Print confirmation that test has passed{% endcomment %}
<p>Yep</p>