Skip to content

Instantly share code, notes, and snippets.

@DanWebb
Last active October 23, 2015 07:20
Show Gist options
  • Save DanWebb/1c4f22691950da71c146 to your computer and use it in GitHub Desktop.
Save DanWebb/1c4f22691950da71c146 to your computer and use it in GitHub Desktop.
Get a shops currency symbol with liquid
{{ 0 | money | remove: '0' | remove: '.' | strip_html }} = '£' or whatever currency your shop is set to
<!-- WARNING: the following will not work -->
{{ shop.currency }} = the 3 letter currency code i.e. 'GBP' but we want the symbol (£)
{{ shop.money_format }} = '£{{amount}}'
{{ shop.money_format | remove: '{{amount}}' }} = error because of the curly braces
{{ shop.money_format | remove: '{' | remove: 'amount' | remove: '}' }} = error (even a single closing curly brace will error)
{{ shop.money_format | slice: 1 }} === 's'?
{{ shop.money_format | truncate: 1 }} === '...'?
{% capture currency_symbol %}{{ shop.money_format }}{% endcapture %}
{{ currency_symbol | slice: 1 }} === 's'
{% capture currency_symbol %}{{ shop.money_format }}string{% endcapture %}
{{ currency_symbol | slice: 1 }} === 's'
@ckhatton
Copy link

👍 Noice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment