Howdy Cesar,
I would love to help you with this.
There is no single function that does this. However, it should be easy to create you own. I’d first start with by copying the source from the function that you quoted:
[php]
/**
* Counts the total number of tickets still available for sale for a
* specific event.
*
* @param null $event
*
* @return int
*/
function tribe_events_count_available_tickets( $event = null ) {
$count = 0;
if ( null === ( $event = tribe_events_get_event( $event ) ) ) {
return 0;
}
foreach ( Tribe__Tickets__Tickets::get_all_event_tickets( $event->ID ) as $ticket ) {
$count += $ticket->stock();
}
return $count;
}[/php]
In there you will notice it is counting theĀ $ticket->stock(); integer. Well there are a coulpleĀ other options available:
$ticket->qty_sold();
$ticket->qty_pending();
If you want it to include sold tickets as well as pending, and of course the stock available, then I would count all three of those. Just rename the function, add each of them to the total, and you’re golden.
Does that all make sense? Will that work for you? Please let me know.
Cheers!
– Brook