Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active September 6, 2019 14:31
Show Gist options
  • Save joshfeck/89fafd7db45173c1e9bb6bf39aa6a14f to your computer and use it in GitHub Desktop.
Save joshfeck/89fafd7db45173c1e9bb6bf39aa6a14f to your computer and use it in GitHub Desktop.
Adds a "Transaction Number" column to the Event Espresso > Registrations page. Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE_manage_event-espresso_page_espresso_registrations_columns',
'my_filter_registration_list_table_columns',
10,
2
);
add_action(
'AHEE__EE_Admin_List_Table__column_txnnumber__event-espresso_page_espresso_registrations',
'my_registration_list_table_txnnumber_column',
10,
2
);
/**
* this function adds the column name to the array of table headers
*
* @param array $columns
* @param string $screen
* @return array
*/
function my_filter_registration_list_table_columns( $columns, $screen ) {
if ( $screen === "espresso_registrations_default" ) {
$offset = isset($columns['TXN_paid']) ? 'TXN_paid' : '_REG_paid';
$columns = EEH_Array::insert_into_array(
$columns,
array( 'txnnumber' => 'Transaction Number' ),
$offset,
false
);
}
return $columns;
}
/**
* this function echoes out the data you want to appear in your custom column.
*
* @param \EE_Registration $item
* @param string $screen
*/
function my_registration_list_table_txnnumber_column( $item, $screen ) {
if ( $screen === "espresso_registrations_default" && $item instanceof EE_Registration ) {
$txn = $item->transaction();
if ($txn instanceof EE_Transaction) {
$txn_payments = $txn->approved_payments();
foreach($txn_payments as $txn_payment) {
if($txn_payment instanceof EE_Payment) {
echo $txn_payment->txn_id_chq_nmbr() . '<br>';
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment