Last active
July 5, 2017 13:48
-
-
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)
This file contains hidden or 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 | |
| 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