The original poster needs to create a discount code (INFLUENCER20) that applies 20% off orders, but caps the maximum discount at $100 (meaning orders over $500 receive only $100 off instead of the full 20%).
Proposed Solutions:
• Shopify Script approach: Create a 0% discount code in Shopify, then use the Script Editor app with custom Ruby code that:
Checks if the cart has the specific discount code
Applies $100 flat discount when cart subtotal ≥ $500
Applies 20% discount when cart subtotal < $500
Distributes the discount proportionally across line items
• Alternative recommendation: Use Shopify Functions instead of Scripts (which are being deprecated). The Nex Discounts app was suggested as a no-code solution that supports capped percentage discounts.
A complete code example was provided for the Script Editor approach, including logic for calculating proportional discounts across cart items.
Summarized with AI on October 27.
AI used: claude-sonnet-4-5-20250929.
I’m having a hard time using the script editor to figure out how I can implement this:
I’ll give an influencer a promo code, say, INFLUENCER20, where it’ll give all who use it 20% discount on their total order—but only up to $100. If their carts, therefore, exceed $500, instead of getting 20% they max out their discounts to just $100.
# Check the cart has a discount code and if so it equals the campaign if Input.cart.discount_code and Input.cart.discount_code.code == ‘INFLUENCER20’
# Conditions for when the maximum discount value applies, in this case 500 or more if Input.cart.subtotal_price >= Money.new(cents:50000) # Value of the maximum discount that the cart will have max_discount = 100
# Get Float value of the cart’s cents variable in dollars cart_subtotal_float = Float((Input.cart.subtotal_price.cents / 100).to_s)
# For each line item Input.cart.line_items.each do |line_item| # Get Float value of line item’s cents variable in dollars line_price_float = Float((line_item.line_price.cents / 100).to_s)
# Calculate percentage the line items price should be reduce to percentage = 1 - (((line_price_float / cart_subtotal_float) * max_discount) / line_price_float) # Multiple the line item by the percentage value it needs to be line_item.change_line_price(line_item.line_price * percentage, message: “$100 off”) end
# If they are under the threshold reduce every line item by 0.2 (20% off) elsif Input.cart.subtotal_price < Money.new(cents:50000) Input.cart.line_items.each do |line_item| line_item.change_line_price(line_item.line_price * 0.8, message: “20% off”) end end
Since Shopify Scripts are being deprecated soon, it’s a good idea to move to Shopify Functions for more future-proof discount logic.
I came across an app called Nex Discounts that lets you set exactly the kind of capped percentage discount you’re talking about — for example, 20% off up to $100 max. It’s easy to set up and works great for influencer codes like the one you mentioned.