Ad
Shopify Slice Function Returns '<'
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.
Ad
Answer
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 span.money
because you are using currency switcher.
<span class="money" >${{amount}} USD<span>
Easly you can use the filter strip_html
to remove the span.money
.
{% assign symbol = symbol | strip_html | slice: 0 %}
Ad
source: stackoverflow.com
Related Questions
- → Does anyone know how to solve IP canonicalization with shopify platform?
- → How can I add a featured image from a blog post to my homepage on shopify
- → Shopify - Get list of product from a specific collection
- → Shopify webhooks not wanted
- → Comparing two large files are taking over four hours
- → Need "add to cart" button price to update with correct amount depending on what checkbox is checked
- → How to append a variable inside another vaiable name in liquid html
- → GET /admin/webhooks.json returns an empty array
- → Javascript function not getting executed properly
- → How to give border to to current displaying border
- → Shopify background image
- → Dynamic Attribute Names in Shopify Cart
- → What after added shopify store into shipstation
Ad