Show extra information in section “Totals”
The Totals section in Phone Orders displays the cart subtotal, shipping, taxes, and order total. The wpo_cart_updated_additional_data filter lets you append extra rows to this section — for example showing a customer’s available account funds balance, a loyalty points balance, or any other order-relevant value from a third-party plugin.
The example below uses WooCommerce Account Funds to show the selected customer’s funded account balance alongside the order total, giving the agent visibility of how much the customer has available to spend without leaving the Phone Orders screen.
Code Sample
Add the following snippet to your child theme’s functions.php or the Code Snippets plugin:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
if ( class_exists( 'WC_Account_Funds' ) ) { add_filter( 'wpo_cart_updated_additional_data', function ( $additional_data, $cart_data ) { if ( !empty( $cart_data['customer']['id'] ) ) { $additional_data[] = array( 'title' => __( 'Amount Funded', 'woocommerce-account-funds' ), 'value_without_tax' => '', 'value_total' => WC_Account_Funds::get_account_funds( $cart_data['customer']['id'], true ), ); } return $additional_data; }, 10, 2 ); } |
Code Explained (for Developers)
| Element | Description |
|---|---|
wpo_cart_updated_additional_data | A Phone Orders filter that fires after cart totals calculate. It passes the current array of extra rows to display in the Totals section and the full cart data. Return an appended array to add new rows. |
$additional_data | The existing array of extra Totals rows. Each entry must contain title, value_without_tax, and value_total keys. |
$cart_data['customer']['id'] | The WordPress user ID of the selected customer. The snippet checks it’s not empty before querying Account Funds, since no balance exists when no customer is selected. |
'title' | The label that appears in the Totals section row — in this example 'Amount Funded', pulled from the Account Funds text domain so it translates correctly. |
'value_without_tax' | The pre-tax value for the row. Account Funds balances are not tax-bearing values, so this passes an empty string. |
'value_total' | The formatted value shown in the row. WC_Account_Funds::get_account_funds( $user_id, true ) returns the customer’s current balance formatted as a currency string. |
Adapting this for other plugins: replace the
class_exists()check and thevalue_totalcalculation with any value your plugin exposes for the selected customer. Thewpo_cart_updated_additional_datafilter accepts any number of rows — call$additional_data[] = array(...)multiple times to add more than one extra row.
How to Apply This Code
- Open Appearance → Theme File Editor or the Code Snippets plugin.
- Paste the snippet into your child theme’s
functions.phpor create a new dedicated snippet. - Save and open Phone Orders.
- Select a customer who has an Account Funds balance.
- Verify the Amount Funded row appears in the Totals section showing the correct balance.
⚠️ Always use a child theme or Code Snippets — parent theme files get overwritten on theme updates.
When Should You Use This?
Use this hook whenever an agent needs quick access to customer-level financial data while creating an order — without opening a separate admin screen. Account Funds balances, loyalty point values, credit limits, and outstanding invoice totals are all good candidates for the Totals section.