Difference between revisions of "Functions:dollarFormat"

From Whirlwind eCommerce Wiki
Jump to: navigation, search
 
Line 4: Line 4:
  
 
== Syntax ==
 
== Syntax ==
$stringDollarAmount = eV::dollarFormat($decimalAmount);
+
$stringDollarAmount = eV::dollarFormat($decimalAmount,$forceCents);
  
 
== Paramaters ==
 
== Paramaters ==
 
*$decimalAmount DECIMAL
 
*$decimalAmount DECIMAL
 
:: decimal amount to be converted to dollar value
 
:: decimal amount to be converted to dollar value
 +
*$forceCents BOOL Optional
 +
:: dictates if the dollar value returned should always be extended out 2 decimal places. Defaults to true.
  
 
== Return Values ==
 
== Return Values ==
Line 19: Line 21:
 
echo eV::dollarFormat(126.5);
 
echo eV::dollarFormat(126.5);
 
// outputs $126.50
 
// outputs $126.50
 +
 +
echo eV::dollarFormat(126);
 +
// outputs $126.00
 +
 +
echo eV::dollarFormat(126,false);
 +
// outputs $126
  
 
</source>
 
</source>
 +
 +
== History ==
 +
10/30/2008 Mark W. : Added forceCents attribute.

Latest revision as of 18:07, 30 October 2008

Page Template Managers

Page Template Functions

Description

Converts a decimal to dollar output including preceding $ sign.

Syntax

$stringDollarAmount = eV::dollarFormat($decimalAmount,$forceCents);

Paramaters

  • $decimalAmount DECIMAL
decimal amount to be converted to dollar value
  • $forceCents BOOL Optional
dictates if the dollar value returned should always be extended out 2 decimal places. Defaults to true.

Return Values

Returns a string dollar version of the provide decimal amount.


Examples

echo eV::dollarFormat(126.5);
// outputs $126.50
 
echo eV::dollarFormat(126);
// outputs $126.00
 
echo eV::dollarFormat(126,false);
// outputs $126

History

10/30/2008 Mark W. : Added forceCents attribute.