Closed (fixed)
Project:
Ubercart
Version:
7.x-3.x-dev
Component:
Products
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
26 Jan 2012 at 22:04 UTC
Updated:
11 Oct 2012 at 20:32 UTC
Sorry for the simple question, but I have basically no PHP experience. I'm theming my invoice. I have:
<?
php print $product->price
?>
I want it to be formatted $00.00 but it keeps formatting 00.00000.
How can I change this to the format that I want? Thanks!
Comments
Comment #1
tr commenteduc_currency_format($product->price)
Comment #2
jan101 commentedsee:
http://php.net/manual/en/function.number-format.php
http://www.php.net/manual/en/function.money-format.php
Comment #3
tr commented@jan101: Those PHP functions are poor choices for this task because they ignore the currency symbol, symbol location, precision, and decimal/thousands separators chosen in the Ubercart administration menus for the site, require you to hard-wire a format into your template, and prevent your site from working with multiple currencies. All display of pricing in Ubercart should be passed through uc_currency_format().
Comment #4
mrpeanut commentedThank you, TR. Kind of sad that something that simple can be a stumbling block, but without much PHP experience, it would have been. Thanks again!
Comment #6
mailfox commentedGood!
echo uc_currency_format($product->price);Comment #7
tr commentedRestoring version.