Skip to content
This repository has been archived by the owner on Aug 30, 2018. It is now read-only.

Shopify.formatMoney in timber.js has incorrect default thousands separator #602

Open
canardos opened this issue Dec 5, 2016 · 0 comments

Comments

@canardos
Copy link

canardos commented Dec 5, 2016

Function Shopify.formatMoney from timber.js has a default thousands separator of ',' and therefore all cases in the below code from the same function produce a ',' thousands separator whereas the first two should not:

switch(formatString.match(placeholderRegex)[1]) {
  case 'amount':
    value = formatWithDelimiters(cents, 2);
    break;
  case 'amount_no_decimals':
    value = formatWithDelimiters(cents, 0);
    break;
  case 'amount_with_comma_separator':
    value = formatWithDelimiters(cents, 2, '.', ',');
    break;
  case 'amount_no_decimals_with_comma_separator':
    value = formatWithDelimiters(cents, 0, '.', ',');
    break;
}

I believe this:

thousands = defaultOption(thousands, ',');

Should be:

thousands = defaultOption(thousands, '');

The decimal and comma separator parameters are also in the wrong order in the calls in the case statements (or the formatWithDelimiters parameter list).

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

No branches or pull requests

1 participant