Skip to content

Instantly share code, notes, and snippets.

@sebastianwestberg
sebastianwestberg / new-drupal-dev-vm.sh
Last active January 23, 2017 23:43 — forked from rgoodie/new-drupal-dev-vm.sh
A function, when added to bash profile, clones the Vagrant Drupal-Dev-VM (https://github.com/geerlingguy/drupal-dev-vm), augments configuration (based on d7 or d8), renames the VM to something other than drupaltest.dev and starts vagrant up. Uses include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
# new drupal vagrant install
# a function, when added to bash profile, clones the vagrant drupal-dev-vm (https://github.com/geerlingguy/drupal-dev-vm),
# augments config (based on d7 or d8), renames the vm to something other than drupalvm.dev and starts vagrant up. uses
# include <newd 7 my-drupal-site> and <newd 8 my-other-drupal-site>.
function newd {
if [ -z "$2" ]; then
echo 'usage: newd <version> <sitename>'
@gterrill
gterrill / booking-deposit.liquid
Last active July 26, 2016 14:08
Add a deposit product to the cart based on cart total
<script>
{% assign deposit = all_products['deposit'] %}
BookingDeposit = function() {
var _this = this;
_this.cart = {{ cart | json }};
_this.depositProduct = {{ deposit | json }};
_this.depositAmount = 0;
_this.depositLine = -1;
_this.cartDepositVariantId = -1;
@asacarter
asacarter / recently.js
Last active December 9, 2015 17:01
Recently jQuery Plugin
// timer function that loops through an array within a given interval
$.timer = function (list, callback, time/*, onFinish, index*/) {
var onFinish = arguments.length > 3 ? arguments[3] : void 0,
index = arguments.length > 4 ? arguments[4] : 0;
if (index < list.length) {
callback.call(this, index, list[index]);
list.__timed = setTimeout(function() {
$.timer(list, callback, time, onFinish, ++index);
}, time);
@cargix1
cargix1 / gist:0039565fd832ac5c4dcd
Created September 23, 2015 16:35
Datepicker validation when using ajax cart
1). Add the following code towards the bottom of your theme.liquid file. Ensure it's above the code shown in step 2.
<script>
function checkDateTime() {
$("[name='checkout']").on("click", function() {
var date = $(".zapietCollectionDate").val();
var locationId = $(".clickCollectLocation").val();
@james-Ballyhoo
james-Ballyhoo / critcss.snippet.js
Created September 18, 2015 08:34
Based off of https://gist.github.com/PaulKinlan/6284142 , but with support for media queries and dumps css to a textarea in a panel stuck to the top of the page. Only tested in Chrome, uses height of window to determine "critical path".
(function(){
if(document.querySelector("#_CRIT_CSS")){return;}
var container = document.createElement("div");
container.id = "_CRIT_CSS";
container.innerHTML = '<textarea cols=80 rows=20></textarea><button id="CRIT_FIND">Find Critical CSS</button><button id="CRIT_CLOSE">Exit</button>';
container.style.position = "fixed";
container.style.top = 0;
container.style.left = 0;
container.style.right = 0;
container.style.backgroundColor = "#FFF";
@lambtron
lambtron / shopify.md
Last active October 23, 2023 17:48
segment event tracking for shopify
title sidebar
Segment Event Tracking for Shopify
Shopify

Segment makes it simple for Shopify merchants to integrate analytics, email marketing, advertising and optimization tools. Rather than installing all your tools individually, you just install Segment once. We collect your data, translate it, and route it to any tool you want to use with the flick of a switch. Using Segment as the single platform to manage and install your third-party services will save you time and money.

The guide below explains how to install Segment in your Shopify store. All you need to get up and running is copy and paste a few snippets of code into your theme editor. (You don't have to edit the code or be versed in JavaScript.) The following guide will show you how, step by step.


@kyledurand
kyledurand / 1.instructions.md
Last active May 10, 2020 22:06
Lookbook – Advanced Filtering

Advanced Filtering for Lookbook

Preface: This needs a lot of cleaning up but on the front end it's beautiful.

Add the icons font from the supply theme. This will work without the icons font.

Add the filters.liquid file to your snippets folder. Include the snippet on the collections.liquid page

See demo here for a limited time: http://simplejacktest.myshopify.com/collections/all

@kyledurand
kyledurand / 1-instructions.md
Last active December 22, 2021 16:39
[Supply] Sub Dropdown Menus

OUTDATED - Use only as inspiration

Nested / Sub Dropdown Menu for (Almost) Any Shopify theme Based off of Timber

  1. Replace site-nav.liquid with the snippet below.
  2. Add the styles below to timber.scss.liquid.
  3. Go make popcorn.
  4. Check your homepage to see if this has worked.
  5. It didn't work.
  6. Eat the popcorn and try to figure out what went wrong.
<center><img src="https://cdn.shopify.com/s/files/1/0250/7563/files/WDLOGO.jpg?332" height="120" style=align="middle";"/></center>
<p>I'm writing to confirm your order {{ order_name }} with {{ shop_name }} on {{ date | date: "%Y/%m/%d" }}. <a href="http://goo.gl/Gbl1E7">Click here to contact us with questions, comments or concerns.</a></p><br />
<p><strong>Order Details</strong></p>
<ul style="list-style-type:none"> {% for line in line_items %} <li> {{ line.quantity }} x {{ line.title }} for {{ line.price | money }} (each) </li> {% endfor %}
</ul>
<br />
@carolineschnapp
carolineschnapp / gist:11167400
Last active December 11, 2016 12:00
LIPs validation
{% if template contains 'product' %}
<script>
jQuery(function($) {
$('form[action="/cart/add"]').submit(function() {
var formIsValid = true;
var message = "Please fill this out and you will be able to add the item to your cart.";
$(this).find('[name^="properties"]').filter('.required, [required="required"]').each(function() {
$(this).removeClass('error');
if (formIsValid && $(this).val() == '') {
formIsValid = false;