Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dylanjhunt/de4d66e145640d5ccee136fdf38da1ca to your computer and use it in GitHub Desktop.
Save dylanjhunt/de4d66e145640d5ccee136fdf38da1ca to your computer and use it in GitHub Desktop.
min_discount_order_amount = Money.new(cents:100) * 50
total = Input.cart.subtotal_price_was
discount = if total > min_discount_order_amount
1
else
0
end
message = "Free shipping if order is over $50"
Input.shipping_rates.each do |shipping_rate|
next unless shipping_rate.source == "shopify"
shipping_rate.apply_discount(shipping_rate.price * discount, message: message)
end
Output.shipping_rates = Input.shipping_rates
@fullstorymarketing
Copy link

I think I love you for this.

@bel-somage
Copy link

You beautiful man.

@Fr4nk19
Copy link

Fr4nk19 commented Dec 23, 2021

Hi guys , someone can you help me to add this script in my shopify store ?

@DeneDevs
Copy link

@Fr4nk19 You need Shopify Plus to use scripts

@nwheaton23
Copy link

This was amazing thank you!
Now, do you know if there is a way to incorporate different cart amount thresholds? A merchant has different shipping zones with different cart amounts before free shipping kicks in, and this would be SWELL for them if we could implement that somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment