Skip to content

Instantly share code, notes, and snippets.

View drabbytux's full-sized avatar

David Little drabbytux

View GitHub Profile
@drabbytux
drabbytux / how-to-add-a-pick-an-option-to-drop-downs.md
Last active March 6, 2017 15:21
Make 'Pick an option' the default choice in product drop-down menus
layout title sidebar_title description nav
default
Make 'Pick an option' the default choice in product drop-down menus
Make 'Pick an option' the default choice for drop-downs
Quick customization to your theme to let customers know there are variants.
group
products
@drabbytux
drabbytux / pick-an-option-theme.js
Last active March 11, 2017 12:40
Make 'Pick an option' the default choice Javascript for theme.js
$(document).ready(function() {
if( typeof(productOptions ) != "undefined" ){
for(i=0;i<productOptions.length;i++) {
if (['a', 'e', 'i', 'o', 'u'].indexOf(productOptions[i][i].substr(0, 1).toLowerCase()) !== -1 ) {
$('.single-option-selector:eq('+ i +')')
.filter(function() {
return $(this).find('option').length > 1
})
.prepend('<option value="">Pick an ' + productOptions[i][i] + '</option>')
.val('')
@drabbytux
drabbytux / get-customization-information-for-products.js
Last active June 22, 2017 00:25 — forked from carolineschnapp/gist:11167400
Get custom information for product javascript for theme.js
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;
message = $(this).attr('data-error') || message;
$(this).addClass('error');
@drabbytux
drabbytux / gist:c2b42736ed543b236cbf6ee956917e64
Last active March 4, 2018 14:13 — forked from carolineschnapp/gist:9122054
Order form to use in a page or collection template.
{% comment %}
Source: https://gist.github.com/carolineschnapp/9122054
If you are not on a collection page, do define which collection to use in the order form.
Use the following assign statement, replace 'your-collection-handle-here' with your collection handle.
{% assign collection = collections.your-collection-handle-here %}
Use the assign statement outside of this comment block at the top of your template.
{% endcomment %}
{% paginate collection.products by 100 %}
@drabbytux
drabbytux / recommend-related-products.md
Last active March 18, 2018 15:31
Recommend related products to your customers
@drabbytux
drabbytux / Size Chart in Sectioned Themes.md
Last active March 21, 2018 11:20 — forked from carolineschnapp/Size Chart in Brooklyn.md
How to add a Size Chart button to Debut and other Sectioned themes. This uses the Magnific Popup plugin may need to installed (instructions below).

What you want

You want a See Size Chart button on the product page:

Alt text

... that once clicked gives you this:

Alt text

@drabbytux
drabbytux / theme.js
Created January 30, 2017 19:20
Hide variants that are sold out theme.js portion
/* Remove variants that are sold out in the dropdown */
jQuery(document).ready(function(){
if(typeof arr_titles_to_remove != 'undefined' ){
var $addToCartForm = $('form[action="/cart/add"]');
var i_title;
for (i_title = 0; i_title < arr_titles_to_remove.length; ++i_title) {
jQuery('.single-option-selector option').filter(function() { return jQuery(this).text() === arr_titles_to_remove[i_title] }).remove();
}
jQuery('.single-option-selector').trigger('change');
@drabbytux
drabbytux / shipping-cart.js
Last active October 30, 2018 02:39
Shipping cart JS
/**
* Module to add a shipping rates calculator to cart page.
*
* Copyright (c) 2011-2016 Caroline Schnapp (11heavens.com)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Modified by David Little, 2016
*/
@drabbytux
drabbytux / 1 Remove Variants from Single Option Variants that are sold out
Last active October 11, 2019 19:38
Remove variables from single variant selector on product pages that are sold out
{% comment %}Place this at the bottom of the section/product.template.liquid file{% endcomment %}
{% if product.options.size == 1 %}
<script>
var product_variants_removed = [
{%- for variant in product.variants -%}
{%- unless variant.available -%}
'{{ variant.title }}',
{%- endunless -%}
{%- endfor -%}
];
@drabbytux
drabbytux / make-image-change-javascript.js
Last active September 22, 2020 22:48
Make Image Change javascript (for theme.js file)
$(document).ready(function() {
thumbnails = $('img[src*="/products/"]').not(':first');
if (thumbnails.length) {
thumbnails.bind('click', function() {
var arrImage = $(this).attr('src').split('?')[0].split('.');
var strExtention = arrImage.pop();
var strRemaining = arrImage.pop().replace(/_[a-zA-Z0-9@]+$/,'');
var strNewImage = arrImage.join('.')+"."+strRemaining+"."+strExtention;
if (typeof variantImages[strNewImage] !== 'undefined') {
productOptions.forEach(function (value, i) {