Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Forked from joshfeck/csv_transaction.php
Last active December 2, 2020 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Pebblo/76d0e1c7cb851a56636b09ef62156059 to your computer and use it in GitHub Desktop.
Save Pebblo/76d0e1c7cb851a56636b09ef62156059 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__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', 'espresso_add_total_taxes_column', 10, 2);
function espresso_add_total_taxes_column( $reg_csv_array, $reg_row ) {
$sub_line_item_details = array();
$registration = EEM_Registration::instance()->get_one_by_ID( $reg_row['Registration.REG_ID'] );
if( $registration instanceof EE_Registration && $registration->is_primary_registrant() ) {
$line_item_id_for_reg = EEM_Line_Item::instance()->get_var(
array(
array(
'Transaction.TXN_ID' => $reg_row['TransactionTable.TXN_ID']
)
)
);
$sub_line_items = EEM_Line_Item::instance()->get_all(
array(
array(
'LIN_parent' => $line_item_id_for_reg,
'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( __( '%1$s %2$s', 'event_espresso' ), $sub_line_item->name(), $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