You are here

function commerce_payment_handler_field_amount::render in Commerce Core 7

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

modules/payment/includes/views/handlers/commerce_payment_handler_field_amount.inc, line 43
Contains the basic amount field handler.

Class

commerce_payment_handler_field_amount
Field handler to allow rendering of the amount using currency formatting.

Code

function render($values) {
  $value = $this
    ->get_value($values);
  $currency_code = $this
    ->get_value($values, 'currency_code');
  switch ($this->options['display_format']) {
    case 'formatted':
      return commerce_currency_format($value, $currency_code);
    case 'raw':

      // First load the full currency array.
      $currency = commerce_currency_load($currency_code);

      // Format the price as a number.
      return number_format(commerce_currency_round(commerce_currency_amount_to_decimal($value, $currency_code), $currency), $currency['decimals']);
  }
}