Last active
March 18, 2020 23:35
-
-
Save joshfeck/4b38327cd36756c8233d345ffd170376 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_filter( | |
'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__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'] ); | |
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 | |
) | |
) | |
); | |
$sub_line_item_details = array(); | |
foreach( $sub_line_items as $sub_line_item ) { | |
$sub_line_item_details[] = $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