Skip to content

Instantly share code, notes, and snippets.

@j7u7l7s
j7u7l7s / product-loop.liquid
Created January 9, 2018 09:49
A small customisation on the the turbo themes search function
{% comment %} Custom Search in Turbo Theme - Excludes untagged products {% endcomment %}
{% assign product_found = false %}
{% assign skip = false %}
{% assign collection_group = products | map: 'id' %}
{% assign collection_group_thumb = collection_group | append : 'thumb' %}
{% assign collection_group_mobile = collection_group | append : 'mobile' %}
{% capture new_row %}
<br class="clear product_clear" />
@j7u7l7s
j7u7l7s / gist:b65863385489a6a3e4b1ef3ad7c3e21c
Last active January 22, 2018 05:54
Cloudzoom in a Width: 100%; container
<style>
/* Move the zoomed image to the align with the top of the main image*/
#cloud-zoom-big {
top:0 !important;
background: #fff;
width: 100% !important;
}
/* In this case the zoom lens' boundary container needed to be nudged to be confined to the main image's container*/
.cloud-zoom-lens {
function defer() {
if (window.jQuery) {
//THE CODE
}
else {
setTimeout(function(){
defer();
}, 250);
}
}
$(window).load(function() {
$('.swatch-image').each(function() {
var srcImageError = ''; // URL Goes here
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
this.src = srcImageError;
}
});
});
{% capture image %}{{ 'test.png' | asset_url | split:'test.png' | first }}{% endcapture %}
var srcURL = '{{ image }}';
//Swatch Script
$('#wjFilterFront option').each(function(i){
//generate the swatches and add matching data attributes to select options
var imageName = $(this).val();
var srcImage = 'https:' + window.srcURL + imageName + '.png';
srcImage.toString();
var index = i++;
var swatch = '<a class="swatch-link" href="javascript:void(0)" data-option-index="' + index.toString() +'"><img class="swatch-image" src="test.png" data-tag="' + imageName + '" ></a>';
@j7u7l7s
j7u7l7s / ajax-call.js
Last active April 20, 2018 12:50
Get all products in collection via ajax.js
$.ajax({
url:'https://michele-mclaughlin-music.myshopify.com/collections/sheet-music?view=ajax',
type:'GET',
success: function(data){
var dataDump =JSON.parse(data);
console.log(dataDump);}
});
@j7u7l7s
j7u7l7s / ajax-checkbox-filter.js
Created April 25, 2018 07:12
Filter products by multiple tags without refreshing the page using checkboxes
function filterProductsByTag(){
var tagList = [];
var tagUrl = '';
var initialURL = '';
$('.tagFilterBox').each( function(){
var tagName = $(this).data('tag');
if ($(this).is(':checked')){
tagList.push(tagName);
}
});
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "defer.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;
$(document).on('click','.productId', function(e){
var qty = 1;
var id = $(this).data('variant');
addItem=function(qty,id,callback) {
var params = {quantity:qty,id:id};
$.ajax({
type: 'POST',
url: '/cart/add.js',
<script>
// (c) Copyright 2016 Caroline Schnapp. All Rights Reserved. Contact: [email protected]
// See https://docs.shopify.com/themes/customization/navigation/link-product-options-in-menus
var Shopify = Shopify || {};
Shopify.optionsMap = {};
Shopify.updateOptionsInSelector = function(selectorIndex) {