Support

Home Forums Event Espresso Premium API to show total tickets sold on an event

API to show total tickets sold on an event

Posted: April 5, 2021 at 7:16 pm


TTBC

April 5, 2021 at 7:16 pm

We have multiple tickets on an event and max ticket number set how do I retrieve the maximum number of tickets for sale and the maximum number sold with the Events API?


TTBC

April 5, 2021 at 7:16 pm

We have multiple tickets on an event and max ticket number set how do I retrieve the maximum number of tickets for sale and the maximum number sold with the Events API?


TTBC

April 5, 2021 at 7:55 pm

I need the following to loop over all events where it uses a last modified date as the starting point. This is what I pass in from my endpoint so I only loop ver changed records.

I need the following data – i see we can get this info into an Events List in the backend but i can not see where the code is as i should be able to turn that list into a custom api endpoint that i could use.
– EVT_ID
– EVT_name
– Total tickets available
– Total tickets sold
– last modified


Tony

  • Support Staff

April 6, 2021 at 3:56 am

Hi there,

May I ask what you mean by the ‘Events API’?

If I were doing this I’d use our model system:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

$events = EEM_Events::instance()->get_all();

foreach($events as $event) {
    if($event instanceof EE_Event) {
        echo $event->ID();
        echo $event->name();
        echo $event->total_available_spaces();
        echo $event->total_available_spaces() - $event->spaces_remaining_for_sale();
        echo $event->modified();
    }
}

You’ll likely want to add some where conditions to the get_all call above or you’ll end up with a growing list each time. See:

https://github.com/eventespresso/event-espresso-core/blob/master/docs/G–Model-System/model-query-params.md

The support post ‘API to show total tickets sold on an event’ 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