Shopify/Timber

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

Opened this issue · 0 comments

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).