Observed on a customer site which was generating amounts like '12.5' at checkout (possibly specific to customisations/modules).
Established with DPS that this was because the GenerateRequest contained amount=12.5 instead of 12.50
I would have thought commerce_currency_amount_to_decimal(12.5, 'NZD') would handle this.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | commerce_dps-2482407-5-commerce_dps_format_number.patch | 2.81 KB | xurizaemon |
| #1 | commerce_dps-2482407-1-two_decimal_places.patch | 1.12 KB | xurizaemon |
Comments
Comment #1
xurizaemonComment #2
xurizaemonComment #3
millionleaves commentedI just hit this issue on a new site when trying to implement Shipwire. Looks like the Shipwire Commerce module was passing values like '11.9' rather than '11.90'.
This patch fixed the issue on the latest -dev version (June 14 release).
Thanks, as always!
Comment #4
xurizaemonI don't *really* want to commit this patch because I suspect it'll wreak havoc with other currencies. Need to take a moment to work out why commerce_currency_amount_to_decimal(12.5, 'NZD') is not doing what I expected instead ...
Comment #5
xurizaemonOK, here's a revised patch @millionleaves.
Turns out
commerce_currency_amount_to_decimal(12.5, 'NZD')makes sure the number is a decimal, but doesn't try to round or format to two decimal places. So I added a tiny function to handle that.Keen for feedback esp if you have a multicurrency site. (Tests OK for me so far.)
Comment #6
millionleaves commentedThanks for the revised patch - sorry, hadn't seen it earlier.
I had another site come up with the same issue today, and the latest patch fixed it.
This site is not running Shipwire. The only thing I can can think of is that the site is using the Commerce Bulk Product Creation module. It's possible that there is a flaw in the way it creates prices for each product variation.
Comment #8
xurizaemon