Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active July 22, 2020 10:49
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 Pebblo/fa50e1f659b0d2e8ccbb9c7d09bd8e38 to your computer and use it in GitHub Desktop.
Save Pebblo/fa50e1f659b0d2e8ccbb9c7d09bd8e38 to your computer and use it in GitHub Desktop.
Example of how to include a 'SubTotal', 'Taxable SubTotal' and 'Tax Total' column to the registration CSV report.
<?php //Please do not include the opening PHP tag if you already have one.
add_filter(
'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
'tw_ee_add_additional_finance_columns',
10,
2
);
function tw_ee_add_additional_finance_columns( $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() ) {
$grand_total = EEM_Line_Item::instance()->get_one(
array(
array(
'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
'LIN_type' => EEM_Line_Item::type_total
)
)
);
// Sub Total
$items_total = $grand_total->get_items_total();
// Taxable total
$taxable_total = $grand_total->taxable_total();
// Tax Total
$tax_total = $grand_total->get_total_tax();
$reg_csv_array[ __( 'SubTotal', 'event_espresso' ) ] = $items_total;
$reg_csv_array[ __( 'Taxable SubTotal', 'event_espresso' ) ] = $taxable_total;
$reg_csv_array[ __( 'Tax Total', 'event_espresso' ) ] = $tax_total;
}
return $reg_csv_array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment