Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatMoney utility #9

Open
good-idea opened this issue Jun 13, 2019 · 0 comments
Open

formatMoney utility #9

good-idea opened this issue Jun 13, 2019 · 0 comments
Assignees

Comments

@good-idea
Copy link
Collaborator

Should take a Shopify MoneyV2 object, i.e.

{
  amount: 1499.99,
  currencyCode: 'USD'
}

and format it with the proper symbol and decimal placement. Prices that are .00 cents should have the decimals trimmed: $1500

I just saw this but it looks like you can use some built-in locale formatters for most of this!

new Intl.NumberFormat(locale, {
  style: 'currency',
  currency: currencyCode
}).format(amount);

https://help.shopify.com/en/api/storefront-api/reference/object/moneyv2

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

No branches or pull requests

2 participants