Skip to content

Instantly share code, notes, and snippets.

View clickdees's full-sized avatar

Joey Olaopa clickdees

View GitHub Profile
/*
* Ensure the http protocol is always used on the myshopify.com domains.
* Uses liquid to input the correct URL.
*/
if (window.location.href.match(/https:\/\/.*.myshopify.com/) && top === self) {
window.location.href = window.location.href.replace(/https:\/\/.*.myshopify.com/, 'http://{{ shop.domain }}');
}
/* Sample JavaScript file added with ScriptTag resource.
This sample file is meant to teach best practices.
Your app will load jQuery if it's not defined.
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
Your app does not change the definition of $ or jQuery outside the app.
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2'
once the app is installed, even if the app uses jQuery 1.9.1:
jQuery.fn.jquery => "1.4.2"
$.fn.jquery -> "1.4.2"
*/
@clickdees
clickdees / scripts.js
Created October 9, 2018 19:55 — forked from jbutko/scripts.js
jQuery: Get index of hovered element
$(document).ready(function () {
$('.around li').hover(function () {
var index = $('.around li').index(this);
console.log(index);
}, function () { });
});
// From http://stackoverflow.com/questions/11294012/jquery-get-index-of-hovered-li
DISCOUNTS_BY_QUANTITY = {
4 => 20,
3 => 15,
2 => 10
}
discunted_count = 0
Input.cart.line_items.each do |line_item|
if line_item.variant.product.tags.include?('DiscountTag')
/* Sample JavaScript file added with ScriptTag resource.
This sample file is meant to teach best practices.
Your app will load jQuery if it's not defined.
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
Your app does not change the definition of $ or jQuery outside the app.
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2'
once the app is installed, even if the app uses jQuery 1.9.1:
jQuery.fn.jquery => "1.4.2"
$.fn.jquery -> "1.4.2"
*/
@clickdees
clickdees / README.md
Created March 14, 2019 22:26 — forked from joyrexus/README.md
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@clickdees
clickdees / hide_by_country.rb
Created June 13, 2019 07:42 — forked from imbolc/hide_by_country.rb
Restrict shopify payment method to be shown only in particular countries
def allow_in(gateway, allowed)
if Input.cart.shipping_address and allowed.include?(Input.cart.shipping_address.country_code)
Output.payment_gateways = Input.payment_gateways
else
Output.payment_gateways = Input.payment_gateways.delete_if do |payment_gateway|
payment_gateway.name == gateway
end
end
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mutation Observers</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../video-pages/main.css">
</head>
<body>
<header>
@clickdees
clickdees / compress.liquid
Created September 18, 2019 04:38 — forked from JimmyRittenborg/compress.liquid
HTML Compressor in Shopify Liquid
{% comment %}
Input
{% endcomment %}{% capture _content %}{{ content }}{% endcapture %}{% comment %}
Remove redundant closing tags
{% endcomment %}{% assign _endings = "html head body li dt dd p rt rp optgroup option colgroup caption thead tbody tfoot tr td th" | split: " " %}{% for _element in _endings %}
{% capture _end %}</{{ _element }}>{% endcapture %}
@clickdees
clickdees / gist:cb35bf2e6db4df9df1784a2147a3e2df
Created October 8, 2019 08:02 — 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 %}