Tribe__Tickets__Tickets_Handler::get_total_event_capacity( $post = null )
Get the total event capacity.
Contents
Parameters
-
(int|object) (Required) (null) $post Post or Post ID tickets are attached to
Return
(int)
Source
File: src/Tribe/Tickets_Handler.php
public function get_total_event_capacity( $post = null ) { $post_id = Tribe__Main::post_id_helper( $post ); $has_shared_tickets = 0 !== count( $this->get_event_shared_tickets( $post_id ) ); $total = 0; if ( $has_shared_tickets ) { $total = tribe_tickets_get_capacity( $post_id ); } // short circuit unlimited stock if ( -1 === $total ) { return $total; } $tickets = Tribe__Tickets__Tickets::get_event_tickets( $post_id ); // Bail when we don't have Tickets if ( empty( $tickets ) ) { return $total; } foreach ( $tickets as $ticket ) { // Skip shared cap Tickets as it's added when we fetch the total if ( Tribe__Tickets__Global_Stock::CAPPED_STOCK_MODE === $ticket->global_stock_mode() || Tribe__Tickets__Global_Stock::GLOBAL_STOCK_MODE === $ticket->global_stock_mode() ) { continue; } $capacity = $ticket->capacity(); if ( -1 === $capacity || '' === $capacity ) { $total = -1; break; } $capacity = is_numeric( $capacity ) ? (int) $capacity : 0; $total += $capacity; } return apply_filters( 'tribe_tickets_total_event_capacity', $total, $post_id ); }
Changelog
Version | Description |
---|---|
4.6 | Introduced. |