commerce_currency_format(...) in commerce.module has a typo. The if statement to check if conversion is required is not an equality operator, just assignment and hence always returns TRUE and you cannot disable conversion if you're passing in a decimal amount and not an "amount". The function needs to be corrected to read as below:
function commerce_currency_format($amount, $currency_code, $object = NULL, $convert = TRUE) {
// First load the currency array.
$currency = commerce_currency_load($currency_code);
// Then convert the price amount to the currency's major unit decimal value.
if ($convert == TRUE) { // !!! LINE WITH THE TYPO HERE !!!
$amount = commerce_currency_amount_to_decimal($amount, $currency_code);
}
Checked the latest dev version and it still seems to be there.
Thanks for all the awesome work guys. Love this module, blows Ubercart out of the water from a developer's perspective.
Comments
Comment #1
rszrama commentedNice catch! Thanks for the kind words, and enjoy your first commit to making Commerce even better. ; )
Commit: http://drupalcode.org/project/commerce.git/commitdiff/74ee412
Comment #2
damien tournoud commentedThis is embarrassing and needs tests :)
Comment #3
rszrama commentedSure, let's just repurpose the issue with a better title then.
Apparently the commerce_base.test include file for the Commerce module tests enabling currencies and rounding them, but it doesn't appear to do any testing of the default format function at all. Tests can be against a couple different currencies to catch different formats and one test that converts from an integer to a decimal and another that just assumes you have passed in a decimal.
Comment #4
bojanz commented