Posted by Brad DeForest on August 6, 2010 at 10:13pm
2 followers
| Project: | Ubercart pictured cart block |
| Version: | 6.x-1.0-beta3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
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.
Comments
#1
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
#2
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?
#3
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.