Tiered Discount (Buy More, Save More) via Script Editor

Below are step by step instructions to set up a tiered discount (Buy More, Save More Promo) via the Script Editor app.
  1. Install Script Editor App: https://apps.shopify.com/script-editor
  2. Click Create Script > Line Items > Blank Template
  3. Give it a title and Copy & Paste code below into the Ruby Source Code field
  4. Adjust the spend amounts and percentage amounts within the code accordingly
  Code: # Define spending thresholds, from lowest spend to highest spend. SPENDING_THRESHOLDS = [ { spend: 20000, # spend amount (in cents) discount: 10 # percentage discount }, { spend: 50000, discount: 12 }, { spend: 75000, discount: 15 }, { spend: 100000, discount: 20 } ] # Find any applicable spending threshold. eligible_threshold = nil SPENDING_THRESHOLDS.each do |threshold| if Input.cart.subtotal_price_was.cents >= threshold[:spend] eligible_threshold = threshold end end # Apply threshold. if !eligible_threshold.nil? Input.cart.line_items.each do |line_item| line_item.change_line_price(line_item.line_price * (1.0 - (eligible_threshold[:discount] / 100.0)), message: "#{eligible_threshold[:discount]}% off for purchases over $#{eligible_threshold[:spend] / 100}!") end end Output.cart = Input.cart

Leave a comment