Is it possible to display a price number that is rounded to 2 decimal places? I am using the custom price module that allows me to factor price based on quantity using PHP if then conditions. Once the math is done I sometimes get 4 or 5 digits after the decimal point. It shows correctly in the standard shopping cart.

CommentFileSizeAuthor
#2 Screen shot 2010-12-04 at 1.47.56 PM.png15.42 KBmhunt

Comments

brad deforest’s picture

Status: Active » Closed (fixed)

I didn't look at the setting close enough. There is already a setting for turning on a currency format which when turned on adds $ and rounds to 2 decimal points. Problem solved. Well thought out module. Thanks

mhunt’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new15.42 KB

It's possible bradley was using uc_acc. I'm using http://drupal.org/project/uc_aac [ Ubercart Ajax Attribute Calculations ] and have the same issue even though I have set the formats in '/admin/store/settings/store/edit/format'

Any one have any thoughts?

mhunt’s picture

I had to patch the module to correct the issue I was having by using the 'sprintf' function
lines 948 - 954:

if ($use_curr) {
$price = sprintf("%01.2f", uc_currency_format($item['price']));
}
else {
$price = $item['price'];
$price = sprintf("%01.2f", $item['price']);
}

Note that I am not a php programmer, but this seems to work for me.