Advertisement
BakerMan

Single event page attendee list WooTickets 1.0 (TEC 2.0.11)

Feb 21st, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. // Build a list of attendees
  2. $attendeeList = TribeEventsTickets::get_event_attendees(get_the_ID());
  3. $customerList = array();
  4.  
  5. // Build a list of customers (by order ID)
  6. if (is_array($attendeeList)) {
  7.     foreach ($attendeeList as $attendeeData)
  8.         // To dovetail with WooTickets default mode of operation we're only going to concern
  9.         // ourselves with completed orders, but this clause could be changed
  10.         if ($attendeeData['order_status'] === 'completed') {
  11.             // Record the order ID and number of attendees per order
  12.             if (!isset($customerList[$attendeeData['order_id']])) {
  13.                 $customerList[$attendeeData['order_id']] = 1;
  14.             }
  15.             else {
  16.                 $customerList[$attendeeData['order_id']]++;
  17.             }
  18.         }
  19. }
  20.  
  21. // Iterate through and print the customer's deets in an unordered list
  22. if (count($customerList) > 0) {
  23.     echo '<ul>';
  24.  
  25.     foreach ($customerList as $orderID => $totalAttendees) {
  26.         $order = new WC_Order($orderID);
  27.         $gravatar = '<img src="http://www.gravatar.com/avatar/'.md5(strtolower(trim($order->billing_email))).'">';
  28.         $attendees = "$totalAttendees person(s)";
  29.         echo "<li> $gravatar {$order->billing_first_name} {$order->billing_last_name} &ndash; $attendees</li>";
  30.     }
  31.  
  32.     echo '</ul>';
  33. }
  34.  
  35. // Is no one attending?
  36. else {
  37.     echo '<p>No one is attending. Come on, sign up!';
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement