Skip to content

Instantly share code, notes, and snippets.

View index.js
document.querySelector('#addToCartButton').addEventListener('click', function (event) {
var item = SomethingIdentifyingTheItemID;
addItem(item, (result) => {
// Add any other UI interactions you want
document.addEventListener('cart:added', (event) => {
Cam / object_properties.liquid
Created Oct 30, 2019
Get properties from global objects in liquid for Shopify
View object_properties.liquid
{%- assign object = block.settings.url -%}
{%- if object -%}
{%- if object.type == 'page_link' -%}
{%- assign object = block.settings[link] | remove: '/pages/' -%}
{%- assign title = pages[object].title -%}
{%- elsif object.type == 'collection_link' -%}
{%- assign object = block.settings[link] | remove: '/collections/' -%}
{%- assign title = collections[object].title -%}
{%- elsif object.type == 'product_link' -%}
Cam /
Created Feb 6, 2019 — forked from coolaj86/
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set "Your Name"
npm set ""
npm set ""

npm adduser

View gist:7d2a314b3f153033ef3caf1fbc9f5e6f
<div class="container center">
<h3>Want more?</h3>
<p>Add a exclusive VIP pack</p>
<div class="row no-margin">
<div class="column l4 m4 s12">
<a href="/collections/music">
<img src="">
<h4>Bundle title</h4>
Cam / share.liquid
Last active Sep 17, 2018
Handy ‘lite’ Shopify sharing code
View share.liquid
<!-- Sharing is caring, with love from Cam -->
{% if template contains 'product' %}
<ul class="social-sharing inline-list">
<li title="Share on Twitter"><a target="_blank" href="{{ product.title | truncate: 30 }}&url=http%3A%2F%2F{{ shop.domain }}{{ product.url | replace: '/', '%2F' }}&via=YOURTWITTERNAME">Share on Twitter</a></li>
<li title="Share on Facebook"><a target="_blank" href="{{ shop.domain }}{{ product.url }}">Share on Facebook</a></li>
<li title="Share on Google+"><a target="_blank" href="{{ shop.domain }}{{ product.url }}">Share on Google+</a></li>
<li title="Share on LinkedIn"><a target="_blank" href="{{ shop.domain }}{{ product.url }}&title={{ product.title | truncate: 30 }}&summary={{ product.description | strip_html | truncate: 240 }}&source=http://{{ shop.domain }}{{ product.url }}">Share
Cam / country_codes.json
Created Sep 8, 2018 — forked from orenitamar/country_codes.json
Two letter country code mapping, grouped by continent/region
View country_codes.json
"europe": {
"va": "vatican city",
"ch": "switzerland",
"ad": "andorra",
"ee": "estonia",
"is": "iceland",
"am": "armenia",
"al": "albania",
"cz": "czech republic",
Cam / .htaccess
Created Sep 8, 2018 — forked from louy/.htaccess
Apache .htaccess geographical redirect based on CloudFlare's geo-ip headers
View .htaccess
# add as many as you need...
SetEnvIf CF-IPCountry SY RedirectSubdomain=syria
SetEnvIf CF-IPCountry AE RedirectSubdomain=uae
SetEnvIf CF-IPCountry EG RedirectSubdomain=egypt
# Only redirect if Host is not a subdomain
SetEnvIfNoCase Host ^.+\.example\.com$ !RedirectSubdomain
# Only redirect if cookie "noredirect" doesn't exist
SetEnvIfNoCase ^Cookie$ noredirect=true !RedirectSubdomain
Cam / order-status-product.liquid
Created Jun 20, 2018 — forked from shopifypartners/order-status-product.liquid
Script to load specific content for a particular product, on the order status page
View order-status-product.liquid
{% for line in checkout.line_items %}
<!-- DEBUG looking at {{ line.title }} -->
{% if line.title == 'Red Sports Tee' %}
'<h2>Thanks for your order</h2>',
'<p>Have a 10% discount on us! Use AWESOME18 with your next purchase</p>'
{% endif %}
{% endfor %}
Cam / config
Created Dec 7, 2017
Sample SSH config file
View config
# GitHub
PreferredAuthentications publickey
IdentityFile ~/.ssh/github
# Bitbucket
Cam /
Created Sep 25, 2017 — forked from leonderijke/
Front Export: Little export script for exporting all conversations in a Front App inbox

Front export

Little export script for exporting all conversations in a Front inbox, using the Front API.

When using the awesome Front App, you want to export all conversations in an inbox. For example, for backup purposes.

Three environment variables are needed: