function commerce_payment_handler_field_balance::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_balance.inc, line 43
Class
- commerce_payment_handler_field_balance
- Field handler to be able to show the balance order with currency.
Code
function render($values) {
$order_id = $this
->get_value($values, 'order_id');
// Only render this field if we find a valid order.
if (!empty($order_id) && ($order = commerce_order_load($order_id))) {
$balance = commerce_payment_order_balance($order);
// Output according to the format selected as with price fields.
switch ($this->options['display_format']) {
case 'formatted':
return commerce_currency_format($balance['amount'], $balance['currency_code']);
case 'raw':
return check_plain($balance['amount']);
}
}
}