Created
March 17, 2016 21:33
-
-
Save barryhughes/96245e27bac6c673e8fa to your computer and use it in GitHub Desktop.
Like https://gist.github.com/barryhughes/3be509552be340039f8f but for EDD integration
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 | |
/** | |
* Adds email and name columns to the attendee export data (CSV only). | |
* | |
* Filters via the tribe_events_tickets_attendees_csv_items hook; intended for use | |
* with the initial 4.1 release of Event Tickets and Event Tickets Plus in | |
* combination with EDD only. | |
* | |
* @param array $items | |
* @return array | |
*/ | |
function attendee_export_add_purchaser_email_name( $items ) { | |
$count = 0; | |
foreach ( $items as &$attendee_record ) { | |
// Add the header columns | |
if ( 1 === ++$count ) { | |
$attendee_record[] = 'Customer Email Address'; | |
$attendee_record[] = 'Customer Name'; | |
} | |
// Populate the new column in each subsequent row | |
else { | |
// Assumes that the order ID lives in the first column | |
$order = edd_get_payment_by( 'id', (int) $attendee_record[0] ); | |
$attendee_record[] = $order->email; | |
$attendee_record[] = $order->first_name . ' ' . $order->last_name; | |
} | |
} | |
return $items; | |
} | |
add_filter( 'tribe_events_tickets_attendees_csv_items', 'attendee_export_add_purchaser_email_name' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment