Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Last active March 17, 2016 21:24
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 barryhughes/3be509552be340039f8f to your computer and use it in GitHub Desktop.
Save barryhughes/3be509552be340039f8f to your computer and use it in GitHub Desktop.
ET 4.1: add customer email column to CSV export data
<?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/Event Tickets Plus in combination
* with WooCommerce 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 columns in each subsequent row
else {
// Assumes that the order ID lives in the first column
$order = wc_get_order( (int) $attendee_record[0] );
$attendee_record[] = $order->billing_email;
$attendee_record[] = $order->billing_first_name . ' ' . $order->billing_last_name;
}
}
return $items;
}
add_filter( 'tribe_events_tickets_attendees_csv_items', 'attendee_export_add_purchaser_email_name' );
@barryhughes
Copy link
Author

Updated to add the customer name. Also now draws on the order's billing data, rather than the associated user account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment