Skip to content

Instantly share code, notes, and snippets.

@jimmijazz
jimmijazz / Download-Shopify-CDN-Assets.md
Last active November 26, 2018 04:06 — forked from ridem/Download-Shopify-CDN-Assets.md
Download all Shopify CDN assets from a store

This was 99.99% from here - ridem/Download-Shopify-CDN-Assets.md I've just updated to work with new admin DOM elements and provided instructions.

Instructions

  1. Go to your Shopify admin/settings/files page
  2. Open your browser Dev tools, go to the console

Then, depending on the option you choose:

@jimmijazz
jimmijazz / gist:9f38b640965e26988614cfb493936a18
Created June 7, 2019 05:43
Product Bundling using tags and liquid
{% comment %}
=======================
PROUCT BUNDLING EXAMPLE
=======================
Adding in bundles based on tags
This section gets the product tags, looks for those with outfit:x where x == the product handle. -->
Then concatenates them all into one string.
{% endcomment %}
tag = "hide" # If any line items have this tag, the gateway would be hidden
payment_gateways = ["Credit card", "BitPay"] # Any gateways in this array will be hidden
hide = false
Input.cart.line_items.each do |item|
if item.variant.product.tags.include?(tag)
hide = true
break
end
end
# This script will apply a 100% discount to all shipping methods if the customers who have a tag in the VIP_CUSTOMER_TAG array
# Define the tag that identifies VIP customers.
VIP_CUSTOMER_TAG = ['trade', 'wholesale']
if !Input.cart.customer.nil? # Check there is actually a customer
VIP_CUSTOMER_TAG.each do |tag| # Loop over their tags
if Input.cart.customer.tags.include?(tag.downcase) # Check for upper or lower case
Input.shipping_rates.each do |shipping_rate| # Loop over shipping rates
shipping_rate.apply_discount(shipping_rate.price, message: "Free shipping for Trade and Wholesale Customers!") # Apply discount
totalCartPrice = 0
Input.cart.line_items.each do |item|
totalCartPrice += item.line_price.cents
end
Output.shipping_rates = Input.shipping_rates.delete_if do |shipping_rate|
shipping_rate.name.upcase.start_with?("EXPRESS")
end
# EG - I want to offer 15% off all cycling bib shorts when any of our cycling jerseys are purchased.
# Assumes no limit on how many of these products can be discounted in one cart
cartDiscountAmount = 15 # (Int) Percentage discount to apply. 15 = 15%
cartDiscountMessage = "15% off Pedla bibs" # (String) Message to apple when discounting
cartDiscountCondition = false # (Boolean) Should the cart discount conditions be applied
discountConditionalProductType = "Electronics" # (String) If this product type is in the cart other products may be discounted
discountTargetProductType = "Music" # (String) The product type that should be discounted.
@jimmijazz
jimmijazz / cart-message.liquid
Created October 24, 2019 03:16
Add a messag to product page based on cart value
{% assign shipping_threshold = 15000 %} <!-- this is in cents. 15000 = $150-->
{% assign current_cart = shipping_threshold | minus: cart.total_price %}
{{ current_cart }}
{{ cart.total_price }}
{% if cart.total_price < shipping_threshold %}
<p>Add {{ current_cart | money }} to your cart for free express shiping </p>
{% else %}
<p>Qualify for free express shipping!</p>
{% endif %}
payment_gateways = ["Afterpay", "BitPay"] # Gateways to hide
tag = "lowstock" # Tag to look for
lowStockVariantIDS = [] # Will contain variant ID's of low stock items
# Loop over line items to check if any have low stock tag.
# If product doeshave tag, add it to our lowStockVariantIDs array.
Input.cart.line_items.each do |item|
#Note: this won't be very efficient for products with lots of tags
item.variant.product.tags.each do |tag|
@jimmijazz
jimmijazz / gist:042ba5f206ef5c93853eab7641dbc599
Created August 26, 2020 06:35
[Shopify] Sample title tag generation with tag filtering
<title>
{{ page_title }}{% if current_tags %}{% assign current_tags_joined = current_tags | join: ', ' %} &ndash; {{ 'general.meta.tags' | t: tags: current_tags_joined }}{% endif %}{% if current_page != 1 %} &ndash; {{ 'general.meta.page' | t: page: current_page }}{% endif %}{% unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless %}
</title>
{% comment %} Renders gift with purchase products that merchant selects {% endcomment %}
<style>
.gallery__item:hover {
cursor: pointer;
}
</style>
<script>
function addToCart(variant_id) {