Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.16
Component:
Price
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Apr 2020 at 13:44 UTC
Updated:
30 Sep 2024 at 09:03 UTC
Jump to comment: Most recent
When adding a (commerce_price:number) field in views there's no way to remove the unwanted trailing zeros after the decimal point in the field's Configure field window.

| Comment | File | Size | Author |
|---|---|---|---|
| Screen Shot 2020-04-07 at 11.26.49 pm.png | 19.37 KB | the_glitch |
Comments
Comment #2
the_glitch commentedComment #3
beakerboyWhat is your desired behavior? Round, floor, ceiling, or truncate?
Comment #4
the_glitch commentedusually ceiling but all options would be nice. Also options of decimal scale would be nice too.
Comment #5
jsacksick commentedYou should use the regular price field (not commerce_price:number) and use the default formatter. If you do not want to show the currency code/symbol, you can do that and also remove trailing zeroes.
If you need more customization options, I'd suggest writing your own field formatter.
Comment #6
the_glitch commentedAt this point in time I need to use price:number because I'm using the value in views_simple_math_field formula and it doesn't recognise the numeric value of price fields because of the currency code and symbol.
Comment #8
the_glitch commentedCan somebody please re-open this issue as the unwanted trailing zeros are still an issue?
Comment #9
the_glitch commentedComment #10
alfthecat commented+1 for re-opening this, as I can confirm this is still an issue. In my case, I'm trying to make a "Total sales" block that sums the "Total price" field on orders. When using aggregation, I get results like:
Total: 10, 320.000000
There is no way to change the formatter or apply decimal settings.
Comment #11
alfthecat commentedFor those bumping into this problem, a dirty work around is to install the views_simple_math_field, entering the formula of @yourfield*1 and then setting the rounding to your needs.