Skip to content

Instantly share code, notes, and snippets.

View carolineschnapp's full-sized avatar

Caroline carolineschnapp

  • Shopify
  • Montreal
View GitHub Profile
@carolineschnapp
carolineschnapp / gist:ba16d0f12ab9ba7baefe
Last active June 15, 2022 06:42
Delivery charge collected on the Cart page
<script>
Shopify.Cart = Shopify.Cart || {};
Shopify.Cart.DeliveryCharge = {};
Shopify.Cart.DeliveryCharge.set = function(data) {
jQuery.ajax({
type: 'POST',
url: '/cart/update.js',
@carolineschnapp
carolineschnapp / new_gist_file.liquid
Created July 29, 2014 21:14
Add this to a snippet and include that snippet before the </body> tag. Adds an edit link to edit content. Only shows up if you are logged-in your store's admin.
{{ '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css' | stylesheet_tag }}
<style>
.edit-tool {
float: right;
position: fixed;
right: 0;
top: 70px;
background-color: white;
padding: 5px 10px;
-webkit-box-shadow: -1px 0px 3px 0px rgba(50, 50, 50, 0.6);
{% assign articles = blogs.news.articles | sort: 'title' %}
{% for article in articles %}
{{ article.title }}
{% endfor %}
@carolineschnapp
carolineschnapp / gist:db7fb1cf412b5e0bdeaf
Created May 29, 2014 15:06
Grab the variant currently selected with ?variant=ID in the URL, or the first in stock variant, on page load.
var optionSelectors = new Shopify.OptionSelectors...
// Grab the variant currently selected with ?variant=ID in the URL, or the first in stock variant, on page load.
optionSelectors.selectVariant({{ product.selected_or_first_available_variant.id }});
@carolineschnapp
carolineschnapp / gist:125a6cc0d7264d381fed
Last active February 10, 2025 17:26
Collection sort (alternative)
<div>
<label>Sort by</label>
<select class="sortBy">
<option value="price-ascending">Price: Low to High</option>
<option value="price-descending">Price: High to Low</option>
<option value="title-ascending">A-Z</option>
<option value="title-descending">Z-A</option>
<option value="created-ascending">Oldest to Newest</option>
<option value="created-descending">Newest to Oldest</option>
<option value="best-selling">Best Selling</option>
@carolineschnapp
carolineschnapp / gist:80eee3bab50f920f84b4
Last active June 21, 2021 20:39
JavaScript redirect to force HTTPs
if (location.protocol !== "https:") {
location.protocol = 'https:';
}
@carolineschnapp
carolineschnapp / gist:f014bf78daf2684185d7
Created May 7, 2014 15:11
JavaScript tag to place at the bottom of collection.liquid to handle both the .sort-by select and the .coll-filter selects.
<script>
Shopify.queryParams = {};
if (location.search.length) {
for (var aKeyValue, i = 0, aCouples = location.search.substr(1).split('&'); i < aCouples.length; i++) {
aKeyValue = aCouples[i].split('=');
if (aKeyValue.length > 1) {
Shopify.queryParams[decodeURIComponent(aKeyValue[0])] = decodeURIComponent(aKeyValue[1]);
}
}
}
<div>
<label for="sort-by">Sort by</label>
<select id="sort-by">
<option value="manual">Featured</option>
<option value="price-ascending">Price: Low to High</option>
<option value="price-descending">Price: High to Low</option>
<option value="title-ascending">A-Z</option>
<option value="title-descending">Z-A</option>
<option value="created-ascending">Oldest to Newest</option>
<option value="created-descending">Newest to Oldest</option>
@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;
@carolineschnapp
carolineschnapp / gist:9961168
Last active June 21, 2021 20:44
Variant Images app and the Simple theme
<!-- Only 1 step -->
<!-- Replace this code for the featured image in templates/product.liquid -->
{% if product.featured_image %}
<img id="feature-image" class="desktop" src="{{ product.featured_image.src | product_img_url: 'master' }}" alt="Product Image" data-zoom-image="{{ product.featured_image.src | product_img_url: 'master' }}" alt="{{ product.featured_image.alt | escape }}" />
<img class="mobile" src="{{ product.featured_image.src | product_img_url: 'grande' }}" alt="{{ product.featured_image.alt | escape }}" />
{% if on_sale == true %}<div class="sale">Sale</div>{% endif %}
{% endif %}