Skip to content

Instantly share code, notes, and snippets.

@jnowland
Last active August 29, 2015 14:27
Show Gist options
  • Save jnowland/d1619d14c1d6e56e5a75 to your computer and use it in GitHub Desktop.
Save jnowland/d1619d14c1d6e56e5a75 to your computer and use it in GitHub Desktop.
Credit Card Gist
<select name="CardExpiryYear">
{% assign yearIncreament = globals.site.dateNow | date: "yyyy" -%}
{% for i in (0..10) -%}
{% capture yearIncreament -%}{{ yearIncreament | plus: 1}}{% endcapture -%}
<option value="{{ yearIncreament }}">{{ yearIncreament }}</option>
{% endfor -%}
</select>
{% comment -%} You really dont need to capture {% endcomment -%}
<select name="CardExpiryYear">
{% for i in (0..10) -%}
<option value="{{ globals.site.dateNow | date: "yyyy" | plus: forloop.index0 }}">
{{ globals.site.dateNow | date: "yyyy" | plus: forloop.index0 }}
</option>
{% endfor -%}
</select>
<script>
{% for myProduct in myProductData.items -%}
ga('ec:addProduct', {
'id': {{ myProduct.product.productCode }}',
'name': {{ myProduct.product.name | remove "'" }}',
'category' : '',
'brand' : '',
'variant' : '{{ myProduct.description | remove "'" }}',
'price' : '{{ myProduct.unitPrice }}',
'quantity' : '{{ myProduct.units }}',
});
ga('ec:setAction', 'purchase', {
'id': '{{ myProduct.invoiceNumber }}',
'affiliation': '',
'revenue': '{{ myProduct.totalPrice }}',
'tax': '',
'shipping': '{{ myProduct.shippingPrice }}',
'coupon': '{{ myProduct.discountCodeId }}',
});
{% endfor -%}
</script>
<title>{% if this.['Page Title'] != "" -%}{{ this.['Page Title'] }}{% else -%}{{ name }}{% endif -%}</title>
<meta name="description" content="{% if this.['Meta Description'] != "" -%}{{ this.['Meta Description'] }}{% else -%}{{ description | strip_html | replace: "\n", " " | truncate:155 | lstrip | rstrip }}{% endif -%}">
{% if this.['Image Alt Tag'] != "" -%}{% assign imgAlt = this.['Image Alt Tag'] -%}{% else -%}{% assign imgAlt = name -%}{% endif -%}
{{ imgAlt }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment