Skip to content

Instantly share code, notes, and snippets.

View joe-dempsey's full-sized avatar

joe dempsey joe-dempsey

View GitHub Profile
AddType x-httpd-php54 .php
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
RewriteRule ^(.*)$ http://www.olddomain.com/$1 [L,R=301,NC]
RedirectMatch 301 ^(.*)$ http://newdomain.com/
@joe-dempsey
joe-dempsey / gist:a2827edbaf8068762597ce0fe4a70a1f
Last active October 8, 2019 12:39
google_tag_params (MM)
{% assign prodid = '' %}
{% assign value = '' %}
{% if template contains 'index' %}
{% assign pagetype = 'home' %}
{% elsif template contains 'search' %}
{% assign pagetype = 'searchresults' %}
{% elsif template contains 'collection' %}
{% assign pagetype = 'category' %}
{% elsif template contains 'product' %}
{% capture prodid %}'{{ product.id }}'{% endcapture %}
@joe-dempsey
joe-dempsey / shopify tag loop
Created December 14, 2016 07:58
loop through shopify tags to see if a product has a tag
{% comment %}this tag loop looks for tag border in the product tags - if it finds it then it adds a class="border_this"{% endcomment %}
{% comment %} break is used to escape the loop - more efficient code {% endcomment %}
{% for tag in product.tags %}
{% if tag contains 'border' %}
class="border_this"
{% break %}
{% endif %}
{% endfor %}
@joe-dempsey
joe-dempsey / gist:dd361351452a0114b3fca2dca28e8763
Last active September 28, 2022 16:12
Shopify loops (useful for debugging)
looping variants:
{% for variant in product.variants %}
<p>{{ variant.title }}</p>
{% endfor %}
... more coming soon...
@joe-dempsey
joe-dempsey / shopify email variables based on shipping method title
Last active December 20, 2016 15:12
shopify email variables based on shipping method title
<!-- variable (shipping title downcased) -->
{% capture shipping_title_downcased %}{{ shipping_method.title | downcase }}{% endcapture %}
<!-- logic -->
<!-- if the order shipping method title downcased contains the word collection -->
{% if shipping_title_downcased contains "collection" %}
<h1>You can collect your products from our stores 9-5 on weekdays</h1>
<h3>List collection handles (use for testing)</h3>
{% for item in cart.items %}
{% for collection in item.product.collections %}
<p>{{ collection.handle }}</p>
{% endfor %}
{% endfor %}
{% for item in cart.items %}
@joe-dempsey
joe-dempsey / gist:d4326d7a08790129bcc07a7c08667662
Created January 16, 2017 17:01
dynamic href lang tags liquid shopify
{% comment %}
Here we have 2 stores:
www.urbanexcess.com
www.usd.urbanexcess.com
set dynamic href lang tags for each to avoid dup. content issues
{% endcomment %}
@joe-dempsey
joe-dempsey / gist:38e4f9d848eacaba2f6562bc43e9652f
Created January 16, 2017 21:51
hreflang tags shopify liquid template
<link rel="alternate" hreflang="x-default" href="{{ canonical_url | replace: shop.domain, 'www.mystore.com' }}" />
<link rel="alternate" href="{{ canonical_url | replace: shop.domain, 'www.mystore.com' }}" hreflang="en-GB" />
<link rel="alternate" href="{{ canonical_url | replace: shop.domain, 'www.us.mystore.com' }}" hreflang="en-US" />
<link rel="alternate" href="{{ canonical_url | replace: shop.domain, 'www.mystore.com' }}" hreflang="en" />
@joe-dempsey
joe-dempsey / richsnippet.liquid
Last active December 14, 2023 08:27
Shopify product richsnippet - structured data markup for Shopify product templates
{% assign current_variant = product.selected_or_first_available_variant %}
<div id="richsnippet">
<div itemscope itemtype="http://schema.org/Product">
<meta itemprop="url" content="{{ shop.url }}{{ product.url }}">
<meta itemprop="image" content="{{ product.featured_image.src | img_url: 'grande' }}">
<meta itemprop="name" content="{{ product.title | escape }}">
<meta itemprop="description" content="{{ product.description | strip_html }}">
{% if product.vendor %}<meta itemprop="brand" content="{{ product.vendor }}">{% endif %}