Include messages through Script editor

Shopify Partner
2 0 0

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 = 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"
  puts "Ya es gratuito"
    puts "#{price}"
  puts "#{price_for_freeshipping}"

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!


Shopify Expert
10360 158 2003

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)? 

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.

★ ★
Shopify Partner
2 0 0

Well Jason, that's part of my issue I supose, don't know if there is a way to connect those scripts with the front-end.

3 0 1

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.

8 0 3

In theory you could use .change_properties with a key that starts with an underscore (so that it isn't automatically written out in checkout) and look for that key in your liquid.

However, if you do, see the bug report I just posted.