Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Forked from Pebblo/csv_transaction.php
Last active February 8, 2018 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/ddb49e215869e43effe752aaa5141ad3 to your computer and use it in GitHub Desktop.
Save joshfeck/ddb49e215869e43effe752aaa5141ad3 to your computer and use it in GitHub Desktop.
add a column to the Event Espresso 4 Registrations CSV report that displays the total tax amount for the transaction
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'espresso_add_total_taxes_column', 10, 2);
function espresso_add_total_taxes_column( $reg_csv_array, $reg_row ) {
$registration = EEM_Registration::instance()->get_one_by_ID( $reg_row['Registration.REG_ID'] );
$sub_line_item_details = array();
if( $registration instanceof EE_Registration && $registration->is_primary_registrant() ) {
$sub_line_items = EEM_Line_Item::instance()->get_all(
array(
array(
'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
'LIN_type' => EEM_Line_Item::type_tax_sub_total
),
'order_by' => array( 'LIN_order' => 'asc' )
)
);
foreach( $sub_line_items as $sub_line_item ) {
$sub_line_item_details[] = sprintf( '$%s', $sub_line_item->get_pretty( 'LIN_total', 'localized_float' ) );
}
}
$reg_csv_array[ __( 'Total Taxes', 'event_espresso' ) ] = implode('+', $sub_line_item_details );
return $reg_csv_array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment