View Attendees List On-Line (new or adapted code)

Home Forums Ticket Products Event Tickets Plus View Attendees List On-Line (new or adapted code)

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #939495
    Jeff
    Participant

    I’ve seen this come up several times in the forum, and can see several ways of going about this task.

    In short, all that’s really needed is the ability to post and view the the current attendees list email (from attendees-email.php) on-line (it could then be printed from there, or easily used in a custom print function in admin (via /wp-admin/edit.php?post_type=tribe_events&page=tickets-attendees&event_id=[event-id])) and/or the front end event listing.

    In the particular implementation I have in mind, the latter would be viewable only by users at a high enough permission level, but different Tickets users would adjust as they see fit – might make pubicly viewable/printable, might not), might make a tally viewable, but not other info, etc.

    One past user requested the ability to post attendees lists within the Event as displayed, and was shown “minimal code” to be added, it was suggested, within a custom single.php for doing so. This doesn’t really work taken literally, since it actually needs to be added to the EVENT template, not just whatever theme’s single.php (if pasted there as written it’ll do nothing – I’ve checked!). That code was supplied here: http://pastebin.com/s3qwUPu7

    So, in the interests of saving me some time while I nail down several other things in this generally very excellent plug-in within a plug-in, about to go live any moment!, any idea for a shortcut for posting/viewing/printing the attendees email on-line or for exactly where/how to add the above “minimal code”?

    TIA

    #939598
    Jeff
    Participant

    Have done a little bit of work since posting the above comment on the code linked previously.

    The snippet works if pasted into single-event.php on or around line 83. I’m going to paste a transitional version of it. For our purposes we will want something suitable for printing from new window opened by button-link on Frontend Event-related pages (i.e., list view, calendar as well as single event view) for logged-in users with >n permission levels. But this is the starting point. (And I’d still welcome assistance – I think you ought to make this a core feature…)

    		<?php
    // Build a list of attendees
    // provided code (below) did not work:
    // Build a list of attendees
    //$attendeeList = TribeEventsTickets::get_event_attendees(get_the_ID());
    // $customerList = array();
    // but substituting $event_id for get_the_ID() did
    
    $attendeeList = TribeEventsTickets::get_event_attendees($event_id);
    $customerList = array();
    
    // Build a list of customers (by order ID)
    if (is_array($attendeeList)) {
    	foreach ($attendeeList as $attendeeData)
    		//All orders are being treated as completed order, also suggested code snippet didn't work
    		//	if ($attendeeData['order_status'] === 'completed') {
    			// Record the order ID and number of attendees per order
    			if (!isset($customerList[$attendeeData['order_id']])) {
    				$customerList[$attendeeData['order_id']] = 1;
    			}
    			else {
    				$customerList[$attendeeData['order_id']]++;
    			}
    		}
    //} for deleted if statement intended to count for compelted orders only
    // Iterate through and print the customer's deets 
    // in an Ordered list (changed from unordered so have ready count of purchases)
    // though final version may revert to unordered once columns are fully set up, probably more like attendee email in 
    // attendees-email.php
    
    if (count($customerList) > 0) {
    	echo '<ol>';
    
    	foreach ($customerList as $orderID => $totalAttendees) {
    		$order = new WC_Order($orderID);
    		$gravatar = '<img src="http://www.gravatar.com/avatar/'.md5(strtolower(trim($order->billing_email))).'">';
    		$attendees = "$totalAttendees person(s)";
    		echo "<li> $gravatar {$order->billing_first_name} {$order->billing_last_name} &ndash; $attendees</li>";
    	}
    
    	echo '</ol>';
    }
    
    // Is no one attending?
    else {
    	echo '<p>No one is attending. Come on, sign up!';
    }
    
    ?>
    #939600
    Jeff
    Participant

    (Note: questions by CKM writing for Jeff M)

    #940145
    Gustavo Bordoni
    Keymaster

    Hi Jeff,

    Thanks for reaching out to us, and thanks for effort on trying to do this, we love when users try to solve this kind of problems and share their code.

    Unfortunately this is a big change that I cannot solve for you here on the forums since it’s a big feature request you can go to our User Voice and suggest it there. If you find the solution and want to share we would be very grateful.

    Again, sorry about that, I wish I could help you further on this one.

    My Best Regards,

     

    #940170
    Jeff
    Participant

    Thanks – although somebody could have said you had nothing to offer a couple of days ago when I first posed the question.

    In actuality, it’s not THAT big a project. In fact, I’m very close to having the full-fledged piece done. The only thing I’m missing, and wasting precious time searching for, is the code for pulling 1) ticket description or title, the same product title used by the Woo Cart, for example, or by tickets.php as $ticket->name, and 2) the price that tickets.php echoes from get_price_html($product), and outputting it to the table on the same single-event.php page with the associated attendees gotten in the code above.

    The ticket name is already used in the email, I just don’t know how to get the two values from WC_Order like “billing_last_name” in the code above, or from $attendeeData, or whether I have to get them from somewhere else.

    Any help on this one problem would be greatly appreciated, the sooner the better!

    #940171
    Jeff
    Participant

    (again, you can call me CK – I’m working with Jeff)

    #940180
    Gustavo Bordoni
    Keymaster

    Hi CK,

    That was my bad about the delay, I was consulting with a colleague about how we should address this issue, I mean we want to maybe include that in the future in our codebase that’s why the delay was required, I should have warned you.

    So about the ticket description or title of the items inside of an WC_Order you can use the “get_items” method from that class, then once with the ID of the Post (Ticket) you can use “get_the_title” and “get_the_content” to retrieve the information.

    To retrieve the price you can use WC_Product method called “get_price“.

    Last but not least, you can use the “WC_Order->get_billing_address()” or “WC_Order->get_user()“, both of them should give you information about the user, remember if billing_last_name is a meta value related to the user you might want to look into get_user_meta from WordPress.

    If you have any other questions, ask them as you did in your last post, makes it much easier to us to answer with something valuable for you. Hope I was able to help.

    My Best Regards,

     

    #940415
    Jeff
    Participant

    Thanks, Gustavo.

    I have modified single-events.php for our site so that

    1. Attendee List shows at bottom of event page only to logged users who are “editor”-level and above.

    2. Includes print/view button that opens new window with attendees list.

    3. Can be printed from there – it’s also possible, of course, to add a print button or pop-up, or even to initiate a printing sub-routine on open.

    4. At present, however, I have only preliminary values for Ticket Type and Ticket Price.

    My initial experiments with the methods you recommended achieved small success. I was on a deadline, so didn’t have enough time to research and experiment further. I was able to get the price or one price, but am up against a simple coding question here in relation to transferring a snippet from attendees.php to my new context, in order to get what’s in other locations called the “ticket type.”

    Is this the kind of question you are able to answer here, or do I need to start all over again explaining the whole thing in some other forum? I could try StackExchange, I guess, but it really is focused on a very specific task within your product. At that point, the big feature request will mostly be done, and maybe you’ll have a framework you can adapt for further development.

    –CK MacLeod

    #940693
    Gustavo Bordoni
    Keymaster

    Hi CK,

    I didn’t understand what is your last question, can you explain it a bit further? I can try to answer the question here, no need to open a new ticket.

    My Best Regards,

    #940751
    Jeff
    Participant

    Sorry if I was being excessively polite, and thus confused you, Gustavo. Any help you can give me will be greatly appreciated.

    In short, all I need is the code that would be inserted in the spot indicated in the snippet below by [ticket name]. I hope it doesn’t confuse you, but the snipped includes the "$tickets = TribeEventsTickets::get_event_tickets( $event_id ); piece that I think might have the info I need to extract (used in attendees.php – see below):

    
    <?php
    //code from attendees.php, still trying to figure out how to extract $ticket->name outside of the foreach ticket
    $event = get_post( $event_id );
    $tickets = TribeEventsTickets::get_event_tickets( $event_id );
    $count = 0; 
    
            foreach ($customerList as $orderID => $totalAttendees) {
    	    $count = $count + 1;
                $order = new WC_Order($orderID);
    
    	   ?>
    	   <tr class="attendees"  >
    		<td class="att_tblcol_first" ><?php echo $count ; ?>.</td>
    		<td class="att_participant" width="30%"><?php echo "{$order->billing_first_name} {$order->billing_last_name}" ?><br/><small><?php echo $order->billing_company; ?></small></br></td>
    		<td class="att_signature" > </td>
    		<!--here is where I still haven't figured out what I can use: -->
    		<td class="att_ticket-type" >[ticket name]</td>	
    		<!-- the following works, but cost tells me what the ticket actually cost - 
                    might be better to choose from all available variables...
    		-->
    		<td class="att_ticket-price" align="center"><?php echo tribe_get_cost( null, true ) ?>*</td>
    		<td class="att_paid tblcol_last" > </td>
            </tr>	
    		
    	<?php	
    	}

    Attendees.php uses

    $event = get_post( $event_id );
    $tickets = TribeEventsTickets::get_event_tickets( $event_id );

    then extracts the “ticket type” like so in a foreach for its own list:

    foreach ( $tickets as $ticket ) : ?>
    <strong><?php echo esc_html( $ticket->name ) ?>: </strong>

    But my list is already iterating through a list of customers, getting, for example, the last names, one after the other, such as $order->billing_last_name as in the example above.

    So I think I just need to fill a slot with $ticket->name (and potentially other slots with other information), but I’m not sure how to get it in this context from $tickets.

    I’m confident if you provided the syntax, I could complete this sub-sub-sub-application/add-on, and maybe develop it in a form that other Wooticket users could apply.

    (The next thing we’re working on is group ordering.)

    #940752
    Jeff
    Participant

    oops – forgot again to sign the above CK MacLeod

    #941435
    Gustavo Bordoni
    Keymaster

    Hi CK,

    It’s important to note that a single user can buy more then one ticket, so the code should take care of that too, but following what you requested on your last answer I’ve crafted this code:

    https://gist.github.com/bordoni/6e4543c562fe0182dbd6

    So just to explain, I’ve used WooCommerce Order Items to grab the ticket name, since we do sync from TEC to WooCommcerce.

    I hope I was able to solve your issue.

    My Best Regards,

    #941459
    Jeff
    Participant

    Thanks, Gustavo – you ALMOST made my day and week with that… unfortunately, however, the it’s not echoing anything in at the key point, or perhaps at the “$key” point. In short, $orderTicket->name and $orderTicket->qty are drawing blanks.

    I think it’s almost there – when I print – print_r(array_values($orderTickets)) – $orderTickets’ values, I get differential outputs at each point, with a simple example here:

    Array ( [0] => Array ( [name] => Non-Member [type] => line_item [item_meta] => Array ( [_qty] => Array ( [0] => 1 ) [_tax_class] => Array ( [0] => ) [_product_id] => Array ( [0] => 316 ) [_variation_id] => Array ( [0] => 0 ) [_line_subtotal] => Array ( [0] => 7 ) [_line_total] => Array ( [0] => 7 ) [_line_subtotal_tax] => Array ( [0] => 0 ) [_line_tax] => Array ( [0] => 0 ) [_line_tax_data] => Array ( [0] => a:2:{s:5:"total";a:0:{}s:8:"subtotal";a:0:{}} ) ) [qty] => 1 [tax_class] => [product_id] => 316 [variation_id] => 0 [line_subtotal] => 7 [line_total] => 7 [line_subtotal_tax] => 0 [line_tax] => 0 [line_tax_data] => a:2:{s:5:"total";a:0:{}s:8:"subtotal";a:0:{}} ) )

    Ideally, I’d like to be able to access any one of those items (and sub-items).

    I think I can <i>probably</i> figure it out, but I have a feeling you may know off the top of your head why your suggestion didn’t work the first time (when do they ever?). If you would prefer, I can put further discussion on Github, but I suspect that a lot of would-be customizers scanning this forum would find instructions on getting those named values out of this $orderTickets array useful.

    #941460
    Jeff
    Participant

    eh, shouldn’t have formatted that array as code – feel free to edit it if you have privileges. Here it is again for reference if not:

    Array ( [0] => Array ( [name] => Non-Member [type] => line_item [item_meta] => Array ( [_qty] => Array ( [0] => 1 ) [_tax_class] => Array ( [0] => ) [_product_id] => Array ( [0] => 316 ) [_variation_id] => Array ( [0] => 0 ) [_line_subtotal] => Array ( [0] => 7 ) [_line_total] => Array ( [0] => 7 ) [_line_subtotal_tax] => Array ( [0] => 0 ) [_line_tax] => Array ( [0] => 0 ) [_line_tax_data] => Array ( [0] => a:2:{s:5:”total”;a:0:{}s:8:”subtotal”;a:0:{}} ) ) [qty] => 1 [tax_class] => [product_id] => 316 [variation_id] => 0 [line_subtotal] => 7 [line_total] => 7 [line_subtotal_tax] => 0 [line_tax] => 0 [line_tax_data] => a:2:{s:5:”total”;a:0:{}s:8:”subtotal”;a:0:{}} ) )

    #941461
    Gustavo Bordoni
    Keymaster

    Hi CK,
    I’ve updated the Code on the Gist. Now it should work.

    https://gist.github.com/bordoni/6e4543c562fe0182dbd6

    My Best Regards,

Viewing 15 posts - 1 through 15 (of 23 total)
  • The topic ‘View Attendees List On-Line (new or adapted code)’ is closed to new replies.