Skip to content

Instantly share code, notes, and snippets.

@fredryk
fredryk / about.md
Last active August 29, 2015 14:24 — forked from matcaissy/about.md
@fredryk
fredryk / gist:4503261dc0e6dc057b7f
Created April 2, 2015 17:57
Load jQuery conditionally
<script type="text/javascript" charset="utf-8">
//<![CDATA[
// Including jQuery conditionnally.
if (typeof jQuery === 'undefined') {
document.write({{ "http://ajax.googleapis.com/ajax/libs/jquery/1.9/jquery.min.js" | script_tag | json }});
document.write('<script type="text/javascript">jQuery.noConflict();<\/script>');
}
//]]>
</script>
@fredryk
fredryk / gist:ea274b9911b7e0192926
Created December 29, 2014 16:25
shipping-rates-calculator
{% if settings.show_shipping_calculator %}
<div id="shipping-calculator">
<h5>{{ 'cart.shipping_calculator.title' | t }}</h5>
<div class="grid">
<div class="grid-item col-3 medium--col-6 small--col-12">
<label for="address_country">{{ 'cart.shipping_calculator.country' | t }}</label>
@fredryk
fredryk / Timber Product Grid Fix
Created December 23, 2014 21:11
Fix product grid clearing in IE8
.grid-item {
display: inline-block;
float: none;
margin-bottom: $gutter;
margin-left: -3px;
padding: 0;
}
@fredryk
fredryk / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@fredryk
fredryk / gist:b2455d3d905b2f0a7715
Created July 1, 2014 15:50
first image if no collection image through link-list
{% if link.type == 'collection_link' %}
{% assign collection = link.object %}
<a href="{{ link.url }}" title="Browse our {{ link.object.title | escape }} collection.">
{% if collection.image %}{{ collection.image.src | collection_img_url: 'medium' | img_tag: collection_title }}{% else %}{{ collection.products.first.featured_image | product_img_url: 'medium' | img_tag: collection_title }}{% endif %}
</a>
{% endif %}
@fredryk
fredryk / Saving percentage in selectCallback
Created April 10, 2014 17:02
Show percent of savings through the selectCallback
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
var savings = Math.round((variant.compare_at_price - variant.price) / variant.compare_at_price * 100);
console.log(savings);
$('#add-to-cart').removeClass('disabled').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button
if(variant.compare_at_price == null){
$('.options .price').html('<strong>'+Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}")+'</strong>');
} else {
$('.options .price').html('<strong>'+Shopify.formatMoney(variant.price, "{{shop.money_with_currency_format}}") + '</strong> <span class="compare_at_price">was <del>' + Shopify.formatMoney(variant.compare_at_price, "{{shop.money_with_currency_format}}") + '</del></span> ' + '<span> You save ' + savings + '%</span>');
@fredryk
fredryk / gist:7876601
Created December 9, 2013 17:43
When products are out of stock, how do I indicate that shipping time will be longer for those? Will now work with multiple variants. :)
var selectCallback = function(variant, selector) {
if (variant && variant.available) {
if (variant.inventory_policy == 'continue' && variant.inventory_quantity <= '0'){
console.log("thingeroo");
jQuery('.notice').text('Test');
}
else {
jQuery('.notice').text('');
jQuery('#add-to-cart').removeAttr('disabled').removeClass('disabled'); // remove unavailable class from add-to-cart button, and re-enable button
{% if template == 'article' and article.content contains '<img' %}
{% assign src = article.content | split: 'src="' %}
{% assign src = src[1] | split: '"' | first | replace: '//cdn', 'http://cdn' | replace: 'http:http://', 'http://' %}
<li style="margin-left:10px; width:80px">
<a href="http://pinterest.com/pin/create/button/?url={{ shop.url }}{{ product.url }}&description={{ article.title }}&media={{ src }}" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>
</li>
{% endif %}
@fredryk
fredryk / gist:6731593
Created September 27, 2013 16:53
Updated Simple theme drop-down navigation
<ul id="main-menu" class="accordion">
{% for link in linklists.main-menu.links %}
{% assign has_sub_menu = false %}
{% assign parent_link_active = false %}
{% assign child_list_handle = link.title | handle %}
{% if linklists[child_list_handle] and linklists[child_list_handle].links.size > 0 %}
{% assign has_sub_menu = true %}
{% for l in linklists[child_list_handle].links %}
{% if l.active %}
{% assign parent_link_active = true %}