Hey there,
I made a really simple code to let know the costumers how much left they have to get free shipping, it goes just like this.
price = Input.cart.subtotal_price
price_for_freeshipping = Money.new(cents: 5500)
if price < price_for_freeshipping
resto = price_for_freeshipping - price
message1 = "Te quedan #{resto} para que tu pedido sea gratuito"
puts "Faltan #{resto} para envio gratuito"
else
puts "Ya es gratuito"
puts "#{price}"
puts "#{price_for_freeshipping}"
end
Output.cart = Input.cart
As you can see is pretty simple but still I have a couple of issues here.
First and the most important is that we would love that if the first condition appears to be true, be able to display a message like "You have X € left to get free shipping". (Next step would be something like, hey add one of this sunglasses, showing somehow a couple of sunglasses we need to sell, and then you'll get free shipping!)
Second issue is the object money if I use the puts tho debug my code it says Money: 2$ for example, well my shop is in € so I don't know whi is displaying the object money as dollars instead, in the other side of the coin I would like to get ONLY the number instead the "Money: 2$".
Thanks in advance for your help!
The bigger question would be how do you intend to use Shopify Scripts to show that message on the page (vs outputing via the app console)?
Just in case anyone else stumbles on this thread, I'll throw this out there. It appears the only way to get the message to the page is by one of the existing message arguments from a script method like:
.change_line_price(Moneynew_price, { message: String })
Then making sure the resulting template has an element with .discont-message. Would dig knowing if I am missing something.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |