Skip to content

Instantly share code, notes, and snippets.

# 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.
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
# 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
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
@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 %}
@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: