Free Ground shipping on orders over $150, using discount code FREESHIP.
No way to do this with discount codes. Shipping scripts works (almost):
Set a discount code FREESHIP to 0% off
If discount code = FREE SHIP
if cart > 150
set ground shipping cost to $0
reject discount code and send error
Crane and Canopy -
OK. Here's what I have... let me know if it works for you.
I've created a Discount Code = FREESHIP that is 0% off if order >= $150. I have shipping rate(s) with "ground" in the name. Here is the shipping script:
# Is there a discount code? unless Input.cart.discount_code.nil? Input.shipping_rates.each do |shipping_rate| next unless shipping_rate.name.downcase.include? "ground" # If the shipping rate name includes "ground" AND subtotal > $150 then set free shipping if Input.cart.subtotal_price > Money.new(cents: 100) * 150 shipping_rate.apply_discount(shipping_rate.price * 1.00, message: "Free ground shipping with FREESHIP") end end end Output.shipping_rates = Input.shipping_rates
The customer can't use the Discount Code unless the order subtotal is > $150. If the order subtotal > $150 AND the customer enters Discount Code = FREESHIP, then the script will make "ground" shipping rates free (100% discount).
Hope that helps. Let me know if you have questions.
Thanks for the help. I acutally already have very similar code written up. Just wanted to add an error message and remove the discount if the cart was below $150 (and the code was used). My current solution is to just change the name of the Ground Shipping rate to "Ground Shipping - increase your cart for free shipping". Not ideal, but works. Would be better if i could use the discount.reject method.... but no go cause this is a shipping script.
THanks again for the help though!