Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save omeome762/323b95ad2d404da5bf1ec66f2b83847e to your computer and use it in GitHub Desktop.
Save omeome762/323b95ad2d404da5bf1ec66f2b83847e to your computer and use it in GitHub Desktop.
Free Shipping If Cart Value >$Y (Excluding States You Don't want)
MINIMUM_ORDER_AMOUNT = 75 #dollars required in cart to get discount
MESSAGE = "Spend Just 75$ & Get Freeshipping" #promotional message
if !Input.cart.shipping_address.province.include?("Newyork") && !Input.cart.shipping_address.province.include?("Newyork")
if Input.cart.subtotal_price_was > (Money.new(cents:100) * MINIMUM_ORDER_AMOUNT)
Input.shipping_rates.each do |shipping_rate|
if shipping_rate.name.include?("3 Day Ground")
shipping_rate.change_name("Free Three Day Ground", { message: "" })
shipping_rate.apply_discount(shipping_rate.price, message: MESSAGE)
end
end
end
end
Output.shipping_rates = Input.shipping_rates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment