Support

Home Forums Event Espresso Premium incorrect number of tickets shown in list

incorrect number of tickets shown in list

Posted: July 5, 2018 at 7:29 am

Viewing 5 reply threads


J Baalbergen

July 5, 2018 at 7:29 am

related to an old issue

An attendee bought 2 tickets and a few days later he bought another 2 for the same event. Unfortunately the displayed number on my list was 2.
Is there a way to solve this problem?

Jolanda


Josh

  • Support Staff

July 5, 2018 at 7:40 am

Hi Jolanda,

May I ask does their second purchase show up on the list on a separate line?

Also, if you can post the entire contents of your customized content-espresso_event_attendees.php template that will help provide some context.


J Baalbergen

July 9, 2018 at 5:23 am

Hello Josh,

There’s only 1 line on the list. Here’s the content of the file:

<?php
/**
* Content Template for the [ESPRESSO_EVENT_ATTENDEES] shortcode
*
* @package Event Espresso
* @subpackage templates
* @since 4.6.29
* @author Darren Ethier
*
* Template Args that are available in this template
* @type EE_Attendee $contact
* @type bool $show_gravatar whether to show gravatar or not.
*/
if ( $show_gravatar ) {
$gravatar = get_avatar( $contact->email(),
(int) apply_filters( ‘FHEE__loop-espresso_attendees-shortcode__template__avatar_size’, 32 )
);
} else {
$gravatar = ”;
}
?>
<?php do_action( ‘AHEE__content-espresso_event_attendees__before’, $contact, $show_gravatar ); ?>
<?php $group_size = $contact->get_most_recent_registration_for_event( $event->get(‘EVT_ID’))->get(‘REG_group_size’ ); ?>

  • <?php echo $gravatar . ‘ ‘ . $contact->full_name(). ‘ – ‘ . $group_size; ?>
  • <?php do_action( ‘AHEE__content-espresso_event_attendees__after’, $contact, $show_gravatar ); ?>


    Tony

    • Support Staff

    July 9, 2018 at 8:21 am

    Hi there,

    The ESPRESSO_EVENT_ATTENDEES shortcode pulls all of the contacts for registrations assigned to an event, so if you have multiple ‘group’ registrations assigned to the same contact, you still only pull a single contact.

    Then notice this line:

    <?php $group_size = $contact->get_most_recent_registration_for_event( $event->get(‘EVT_ID’))->get(‘REG_group_size’ ); ?>

    get_most_recent_registration_for_event() pulls the most recent registration for the event on the current contact and the rest of the code tells EE to pull the group size for that most recent registration.

    What that means if a user registers a group of 2 tickets on the event, at that point the latest registration will be one of those registrations from a group registration of 2.

    If they then return at a later date and register another group of, let say 3 tickets, the above will pull the latest registration from that group and return 3.

    Is not a group registration of 5 as they are separate groups and the ‘latest’ registration is only assigned to the second so the above code is working as expected.

    You could change the above line of code to be something like this:

    <?php 
    	$primary_registrations = $contact->get_registrations( 
    		array( 
    			array(
    				'EVT_ID' => $event->get('EVT_ID'),
    				'REG_count' => 1
    			)
    		)
    	);
    	$group_size = 0;
    	foreach($primary_registrations as $registration) {
    		$group_size += $registration->group_size();
    	}
    ?>

    Which pulls all of the primary registrants the current contact has on the event, counts the group size for all of them and combines them (meaning in the above example I gave you the group_size would be 5)


    J Baalbergen

    July 12, 2018 at 1:53 am

    Hi Tony,
    I changed the file as you explained and it works fine! Thank you very much.
    Kind regards,
    Jolanda


    Tony

    • Support Staff

    July 12, 2018 at 3:57 am

    Great 🙂

    Just to note the above code will only work if the user was the primary registrant, as in they were the first details entered on the registration form.

    Viewing 5 reply threads

    The support post ‘incorrect number of tickets shown in list’ is closed to new replies.

    Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

    Event Espresso