Skip to content

Instantly share code, notes, and snippets.

@fnstirling
fnstirling / Shopify Script - Tiered discounts on eligible products
Created Oct 24, 2018
Shopify script for tiered discounts that includes all products counting toward tier amount but only applies discount to eligible products
View Shopify Script - Tiered discounts on eligible products
# Tiered discount campaign that allows for all products to count toward the tier amount but only eligible products be discounted.
# Can't do this in Shopify discounts because the eligible products restriction also restricts the products that can count toward the minimum spend requirement.
# Requires eligible products to have a consistent tag.
# Can do this with just one discount code but we a seperate discount code for each tier for reporting purposes.
# Amounts for the tiers
tier1_amount = Money.new(cents:100) * 160
tier2_amount = Money.new(cents:100) * 120
tier3_amount = Money.new(cents:100) * 80
@fnstirling
fnstirling / humble_bundle_download_all_browser.js
Created Sep 8, 2018
Humble Bundle - Download all books and videos
View humble_bundle_download_all_browser.js
// Put this in Console in the Developer Tools window on the Downloads page of the Humble Bundle you purchased
// Get all the download links
var downloads = [];
$('a').each(function(i) {
if ($(this).attr('href') && $(this).attr('href').includes('dl.humble.com')) {
downloads.push(this);
}
});
console.log("There are " + downloads.length + " downloads");
@fnstirling
fnstirling / dataset_delete.py
Last active May 29, 2018
Domo API Script - Bulk DataSet delete
View dataset_delete.py
# CAUTION: This will DELETE your DataSets
# This is for bulk deleting of Domo DataSets
# Create a new Domo Developer Client (if necessary) - https://developer.domo.com/new-client
# Put your Client details in the id and secret objects below
# Change auth_url to one with the correct scope of your Client (if necessary)
# Uncomment the calls at the bottom and run
# Rerun if you have more than 50 DataSets
# API Reference - https://developer.domo.com/docs/dataset-api-reference/dataset
@fnstirling
fnstirling / Shopify Script - Max discount based on cart value
Created Apr 24, 2018
Shopify script for applying an upper limit on total discount amount based on cart value. Will spread the maximum discount amount proportionately across all cart products. Applies percentage discount to cart products under cart value threshold.
View Shopify Script - Max discount based on cart value
# In this campaign we wanted to have 50% of every product unless the cart value was 200 or more
# If the 200 or more, the maximum discount that could apply was 100
# Wanted to spread that the discount amount across all line items proporinate to its value in the cart
# Do/change following (if required):
# 1. Create a new coupon code in Shopify
# 2. Replace the coupon code evaluation value ('DISCOUNT_CODE') with the new code on line 13
# 3. Change the cart subtotal evaluation amount (Money.new(cents:20000)) on lines 16, 39
# 4. Change the max_discount value (100) on line 18
# 5. Change the discount amount (0.5) on line 41