Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Last active July 5, 2017 13:48
Show Gist options
  • Select an option

  • Save barryhughes/6a669fece7f3e0011024f3f57c16e748 to your computer and use it in GitHub Desktop.

Select an option

Save barryhughes/6a669fece7f3e0011024f3f57c16e748 to your computer and use it in GitHub Desktop.
Helper function to obtain the name of the individual who purchased a ticket (given the ticket/attendee ID)
<?php
function get_woo_ticket_purchaser_name( $ticket_id ) {
$wootickets = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
$attendee_objects = $wootickets->get_attendees_by_id(
$ticket_id,
Tribe__Tickets_Plus__Commerce__WooCommerce__Main::ATTENDEE_OBJECT
);
if ( count( $attendee_objects ) !== 1 ) {
return null; // Could not load the attendee/ticket
}
$attendee = current( $attendee_objects );
return $attendee['purchaser_name'];
}
// Usage (update 1234 to your actual ticket ID)
print get_woo_ticket_purchaser_name( 1234 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment