Change currency

Created on 30 October 2023, about 1 year ago

Hello,

Thank you for this great module.
I'm trying to change the "summarized" currency based on a field (field_currency in the entity).
So far I had only CHF currency, so I did a small change on this function :

function views_summarize_type_currency($data) {
  $total = 0;

  if (!empty($data) && is_array($data)) {
    foreach ($data as $val) {
      // This allows for negative values and values w/commas to be added
      // correctly.
      // $total += (float) preg_replace('/[^0-9\,\.\-]/', '', $val);
      $total += (float) preg_replace('/[^0-9\.\-]/', '', $val);
    }
    $total = number_format($total, 2);
    
  }
 
  $text = t('Total:');
  return ['#markup' => '<div class="label">' . $text . '</div> CHF&nbsp;' . $total];
}

I'd like to get dynamic, how can I get the field_currency value ?
I found this thread but it didn't help me : https://drupal.stackexchange.com/questions/308755/how-to-get-a-rendered-...

Thanks for your help!

💬 Support request
Status

Active

Version

1.1

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024