function hook_commerce_payment_totals_row_info in Commerce Core 7
Defines rows for use in payment totals area handlers on Views.
The payment totals area handler totals the amount of payments received by currency for all the payment transactions in a View. The array of totals are is used to build a table containing rows for each of the totals and/or the remaining balance of the order by default. Other modules may use this hook to add additional rows to the table.
Parameters
$totals: An array of payment totals whose keys are currency codes and values are the total amount paid in each currency.
$order: If available, the order object to which the payments apply.
Return value
An array of table row data as expected by theme_table(). Row arrays may contain an additional weight key with the value being an integer used to sort the rows prior to display.
See also
commerce_payment_commerce_payment_totals_rows()
commerce_payment_commerce_payment_totals_row_info()
1 function implements hook_commerce_payment_totals_row_info()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- commerce_payment_commerce_payment_totals_row_info in modules/
payment/ commerce_payment.module - Implements hook_commerce_payment_totals_row_info().
1 invocation of hook_commerce_payment_totals_row_info()
- commerce_payment_totals_rows in modules/
payment/ commerce_payment.module - Returns a sorted array of payment totals table rows.
File
- modules/
payment/ commerce_payment.api.php, line 33 - Hooks provided by the Payment module.
Code
function hook_commerce_payment_totals_row_info($totals, $order) {
$rows = array();
if (count($totals) <= 1) {
// Add a row for the remaining balance on the order.
if ($order) {
$balance = commerce_payment_order_balance($order, $totals);
$rows[] = array(
'data' => array(
array(
'data' => t('Order balance'),
'class' => array(
'label',
),
),
array(
'data' => commerce_currency_format($balance['amount'], $balance['currency_code']),
'class' => array(
'balance',
),
),
),
'class' => array(
'order-balance',
),
'weight' => 10,
);
}
}
return $rows;
}