Currency formatting with comma

What’s the easiest way to format a 6 digit number (e.g. 125000 into 125,000) with a comma?

So far, it seems like I would have to split the number into a character array and add a comma every third number from the end. I hope I’m wrong.

I already tried humanize function.

I’m not sure but you might be able to use printf on it.

Nope, the function was numFormat.

See also background:

2 Likes

Thanks. That worked great.

Are You setting up a snipcart button?
here are some trick, add .00 to the template.
ex. data-item-price="{{.Params.price}}.00"
Cheers! :wink:

1 Like

Close. I’m setting up PayPal buttons to work in a pricing table. From the suggestion from RickCogley I got it working like this in the shortcode:

Total ${{$column.pp_amount | lang.NumFmt 2 }}
1 Like

@pricestamp you can “fence” code in here, between three backticks, like:

```
Total ${{$column.pp_amount | lang.NumFmt 2 }}
```

I edited your post to show it. FYI.

1 Like