Shopify Slice Function Returns '<'

- 1 answer

I need to extract currency symbol in Shopify template. So far I've written:

{% assign symbol = product.price | money %} //creates a variable which holds price with currency symbol
{% assign symbol = symbol | slice: 0 %} //should return first char out of a string
{{ symbol }} //prints the variable

Unfortunately last line returns the < char.

Right now I'm out of ideas how to make this work. I know that Shopify can display currency by {{ shop.currency }} method, but it returns currency name instead of currency symbol.



Check the money format which is set in the Store Settings Settings > General > Standards and formats > Currency > Change formatting there are:

  • "HTML with currency"
  • "HTML without currency"

By default they are ${{amount}} USD and ${{amount}}, but they are wrapped them in because you are using currency switcher. <span class="money" >${{amount}} USD<span>

Easly you can use the filter strip_html to remove the

{% assign symbol = symbol | strip_html | slice: 0 %}