Round Commerce Price: in tpl.php or template.php Currently I'm using Commerce and Commerce Multicurrency to our currency in Indonesia.

Sometimes there is a price to numbers that are not rounded.

With print render ($ content ['product: commerce_price']) I get the original price.

I've tried to edit the tpl.php file and the results are as desired.

number_format (round ($ price, -4), 0);


2,511,000 into 2,500,000
2,565,000 into 2,600,000

But after some reading and hopefully not misread. That is not good in tpl.php, but should be in template.php or modules.

Please advise to help me.
A better way to adjust currency formatting, using the relevant Commerce currency hooks, is with 

hook_commerce_currency_info_alter

and adding your own commerce_currency_format handler

e.g:

/**
 * hook_commerce_currency_info_alter
 * 
 * Add custom currency format to selected currencies
 */
function MY_MODULE_commerce_currency_info_alter(&amp;$currencies){
  $currencies['IDR']['format_callback'] = 'MY_MODULE_commerce_currency_format';
}

/**
 * Currency format callback
 *
 * Remove decimal places from output
 * while keeping commerce_amount_to_decimal formatting the same
 *
 * See: commerce_currency_format
 */
function MY_MODULE_commerce_currency_format($amount, $currency, $object = NULL, $convert = TRUE) {

  // Format the price as a number.
  // In our case, we remove decimal places
  $price = number_format(commerce_currency_round(abs($amount), $currency), 0, $currency['decimal_separator'], $currency['thousands_separator']);

  // Establish the replacement values to format this price for its currency.
  $replacements = array(
    '@code_before' =&gt; $currency['code_placement'] == 'before' ? $currency['code'] : '',
    '@symbol_before' =&gt; $currency['symbol_placement'] == 'before' ? $currency['symbol'] : '',
    '@price' =&gt; $price,
    '@symbol_after' =&gt; $currency['symbol_placement'] == 'after' ? $currency['symbol'] : '',
    '@code_after' =&gt; $currency['code_placement'] == 'after' ? $currency['code'] : '',
    '@negative' =&gt; $amount &lt; 0 ? '-' : '',
    '@symbol_spacer' =&gt; $currency['symbol_spacer'],
    '@code_spacer' =&gt; $currency['code_spacer'],
  );

  return trim(t('@code_before@code_spacer@negative@symbol_before@price@symbol_spacer@symbol_after@code_spacer@code_after', $replacements));
}