It would be good if you add an option for use other currencies than dollars.
For example i need to calculate total from euros (€) and to use the euro format (eg. 1.200,30 € or 10,02 € or 50.800,50 €).
Can you add this in the next release?
Thanks!

Comments

rolkos’s picture

I need the same.

hlopes’s picture

Just override this function on your PHP template.

/**
 * Theme: Total value for a currency amount
 */
function theme_views_summarize_type_currency($variables) {
  $data = $variables['data'];
  $total = 0;
  foreach ($data as $val) {
    $total += (float) preg_replace('/[^0-9\.]/', '', $val);
  }
  return '<div class="label">' . t('Total:') . '</div>' .
    sprintf('$%.02f', $total);
}

I've used something like

  foreach ($data as $val) {
    $total += (float) preg_replace('/[^0-9\.]/', '', $val);
		$symbol = preg_replace('/[0-9\. ]/', '', $val);
  }

And then used $symbol down below on the return.

  $ret  = '<div class="summarize-label">' . t('Total:') . '</div>';
  $ret .= '<div class="summarize-value">' . $symbol .' '. sprintf('%.02f', $total) .'</div>';

This works, as long as the fields to be added up are rendered with a currency symbol.

oadaeh’s picture

oadaeh’s picture

I'm not sure how far I want to go with this, but I was thinking that and admin settings page, where you could specify all the deatails of how you want your numbers displayed, might give everyone exactly what they want.

mojiro’s picture

zeip’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Component: Miscellaneous » Code
Issue summary: View changes

Perhaps this could be done with Currency API? There is a patch in #1876548: Changes for presentation logic of views summary for sites with Commerce available.

nwom’s picture

Status: Active » Closed (duplicate)

There is a patch that fixes this in the following issue: #1876548: Changes for presentation logic of views summary