Spend another X and get free shipping Checkout

KDO1
New Member
3 0 0

Hi all, Trying to figure out how to format the below script to stop the "spend" from displaying "#<Money: "1.03$">" and only display " $1.03". the script is below:

 

min_discount_order_amount = Money.new(cents:100) * 25
total = Input.cart.subtotal_price_was
spend = min_discount_order_amount - total
discount = if total > min_discount_order_amount
1
else
0
end
message = "Spend another #{spend} to get free shipping"

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

0 Likes