Ticket::get_qty_pending( int $ticket_id, bool $refresh = false )
Returns the number of pending attendees by ticket.
Contents
Parameters
- $ticket_id
-
(int) (Required) The ticket post ID
- $refresh
-
(bool) (Optional) Whether to try and use the cached value or not.
Default value: false
Return
(int)
Source
File: src/Tickets/Commerce/Ticket.php
public function get_qty_pending( $ticket_id, $refresh = false ) {
static $pending_attendees_by_ticket = [];
if ( $refresh || empty( $pending_attendees_by_ticket[ $ticket_id ] ) ) {
$pending_query = new \WP_Query( [
'fields' => 'ids',
'per_page' => 1,
'post_type' => Attendee::POSTTYPE,
'meta_query' => [
[
'key' => Attendee::$event_relation_meta_key,
'value' => $ticket_id,
],
'relation' => 'AND',
[
'key' => Attendee::$status_meta_key,
'value' => tribe( Pending::class )->get_wp_slug(),
],
],
] );
$pending_attendees_by_ticket[ $ticket_id ] = $pending_query->found_posts;
}
return $pending_attendees_by_ticket[ $ticket_id ];
}
Changelog
| Version | Description |
|---|---|
| 5.14.0 | Utilize new memoization class. |
| 5.1.9 | Introduced. |