Skip to content

Instantly share code, notes, and snippets.

View drabbytux's full-sized avatar

David Little drabbytux

View GitHub Profile
@drabbytux
drabbytux / Shipping Calculator for Sections.md
Last active December 23, 2023 11:51
Add a shipping rates calculator to your cart page
  1. Copy this code and paste it at the bottom of your Assets/vendor.js file, or if your theme doesn't have a vendor.js file, place it at the very top of the theme.js file. (At the moment, POP requires this to be added at the very bottom of the theme.js file, followed by the next bit).

  2. Add this to the bottom of the Assets/theme.js file:

Shopify.Cart.ShippingCalculator.show( {
  submitButton: theme.strings.shippingCalcSubmitButton,
  submitButtonDisabled: theme.strings.shippingCalcSubmitButtonDisabled,
  customerIsLoggedIn: theme.strings.shippingCalcCustomerIsLoggedIn,
  moneyFormat: theme.strings.shippingCalcMoneyFormat                                     
@drabbytux
drabbytux / get-customization-information-for-products.md
Last active July 26, 2023 06:38
Get customization information for products
layout title description supported nav
default
Get customization information for products
Using line item properties to get custom information for products like monograms, engravings, or other customizations.
false
group
products
@drabbytux
drabbytux / Add tabs to product descriptions.md
Last active February 19, 2023 01:40
Add tabs to product descriptions
@drabbytux
drabbytux / make-image-change-variant-sections
Created December 10, 2016 20:22
make image change variant sections
{% comment %}
Place this in your product.liquid template, at the bottom.
{% endcomment %}
{% if product.variants.size > 1 %}
<script>
var variantImages = {},
thumbnails,
variant,
variantImage,
optionValue,
@drabbytux
drabbytux / Magnific Popup CSS
Last active June 2, 2022 22:36
MFP (Magnific Popup) CSS extras
/*================ Vendor-specific styles ================*/
/* Magnific Popup CSS */
.mfp-bg {
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1042;
overflow: hidden;
position: fixed;
@drabbytux
drabbytux / magnific popup jquery code
Created December 10, 2016 11:08
Magnific Popup js
/*! Magnific Popup - v1.0.0 - 2015-03-30
* http://dimsemenov.com/plugins/magnific-popup/
* Copyright (c) 2015 Dmitry Semenov; */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(a){var b,c,d,e,f,g,h="Close",i="BeforeClose",j="AfterClose",k="BeforeAppend",l="MarkupParse",m="Open",n="Change",o="mfp",p="."+o,q="mfp-ready",r="mfp-removing",s="mfp-prevent-close",t=function(){},u=!!window.jQuery,v=a(window),w=function(a,c){b.ev.on(o+a+p,c)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(c,d){b.ev.triggerHandler(o+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},z=function(c){return c===g&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),g=c),b.currTemplate.closeBtn}
@drabbytux
drabbytux / limit-cart-quantities-to-in-stock-items.md
Last active November 27, 2020 16:19
Limit cart quantities to in-stock items
layout title description nav
default
Limit cart quantities to in-stock items
You can prevent your customers from adding larger quantities to the cart than you have in stock at your online Shopify store.
group
products
@drabbytux
drabbytux / plain-js-make-image-change-javascript.js
Last active October 13, 2020 14:02
Thumbnail changes variant, Plain Javascript
document.addEventListener("DOMContentLoaded", function(){
thumbnails = document.querySelectorAll('img[src*="/products/"]');
function addEventListenerList(thumbnails) {
for (var i = 0, len = thumbnails.length; i < len; i++) {
console.log(thumbnails[i].currentSrc);
thumbnails[i].addEventListener('click', thumbImageSwap, false);
}
}
function thumbImageSwap(){
@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) {
@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 -%}
];