Skip to content

Instantly share code, notes, and snippets.

View dylanjhunt's full-sized avatar

Dylan Hunt dylanjhunt

View GitHub Profile
@dylanjhunt
dylanjhunt / gist:96bd04010919a56222b726ec0246dd2d
Last active November 2, 2023 19:43
Realistic Snow For Your Shopify Website - www.dylanjh.com
<div class="snow"></div>
<style>
.editor-stage .snow {
height:50px;
background: #fff;
}
.snow{
position:fixed;
pointer-events:none;
top:0;
min_discount_order_amount = Money.new(cents:100) * 50
total = Input.cart.subtotal_price_was
discount = if total > min_discount_order_amount
1
else
0
end
message = "Free shipping if order is over $50"
Input.shipping_rates.each do |shipping_rate|
discounted_product = 12275195905
products_needed = [592406273]
products_seen = []
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
products_seen << product.id if products_needed.include?(product.id)
end
Input.cart.line_items.each do |line_item|
@dylanjhunt
dylanjhunt / Filter by size in stock shopify. Step 1 full guide at dylanjh.com
Last active August 3, 2022 12:18
Filter by size in stock shopify. Step 1 full guide at https://dylanjh.com
{% assign sizes = '' %}
{% for product in products limit: limit %}
{% for variant in product.variants %}
{% if variant.available %}
{% assign sizes = sizes | append: variant.options[1] | append: '_' %}
{% endif %}
{% endfor %}
{% endfor %}
{% assign sizesArr = sizes | split: '_' | uniq %}
customer = Input.cart.customer
discount = 0
message = ""
if customer
if customer.orders_count < 1
discount = 1000 #discount amount in cents
message = "New Customer - $10 off"
end
end
puts discount
@dylanjhunt
dylanjhunt / tiered_pricing.rb
Last active April 18, 2022 13:10
Shopify Quantity Discount - Tiered Pricing Shopify Script
DISCOUNTS_BY_QUANTITY = {
10_000 => 20,
1_000 => 15,
100 => 10,
10 => 5,
}
Input.cart.line_items.each do |line_item|
next if line_item.variant.product.gift_card?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
{% assign found_title = false %}
{% for item in checkout.line_items %}
{% if item.variant.id == 7387208286253 %}
{% assign found_title = true %}
{% endif %}
{% endfor %}
{% if checkout.subtotal_price > 10000 and found_title == false %}
<script>
@dylanjhunt
dylanjhunt / impulse theme show variants separately
Last active March 17, 2022 10:45
Showing variants as separate products on the Impulse Shopify theme - https://dylanjh.com
{% assign color_active = false %}
{% for option in product.options %}
{% if option == 'Color' %}
{% assign color_active = true %}
{% endif %}
{% endfor %}
{% if product.variants.size > 1 and color_active == true %}
{% for option in product.options %}
{% if option == 'Color' or option == 'Colour' %}
{% assign index = forloop.index0 %}
@dylanjhunt
dylanjhunt / Show all colors for a product as separate products on collection page
Last active March 11, 2022 16:59
Show all colors for a product as separate products on collection page
{% for product in collection.products %}
{% assign color_active = false %}
{% for option in product.options %}
{% if option == 'Color' %}
{% assign color_active = true %}
{% endif %}
{% endfor %}
{% if product.variants.size > 1 and color_active == true %}
{% for option in product.options %}
{% if option == 'Color' %}
<button type="submit" name="add" class="action_button add_to_cart {% if product.handle contains 'oil-pulling-pack' %}free_item{% endif %}" data-label={{ add_to_cart_label | json }}>