Tribe__Tickets__Ticket_Object::available()
Provides the quantity of Available tickets based on the Attendees number
See also
- Tribe__Tickets__Tickets_Handler::get_ticket_max_purchase(): Use instead to get the front-end quantity.
Return
(int)
Source
File: src/Tribe/Ticket_Object.php
public function available() {
// if we aren't tracking stock, then always assume it is in stock or capacity is unlimited
if ( ! $this->managing_stock() || -1 === $this->capacity() ) {
return -1;
}
$values[] = $this->inventory();
$values[] = $this->capacity();
$values[] = $this->stock();
// What ever is the lowest we use it
$available = min( $values );
// Prevents Negative
return max( $available, 0 );
}
Changelog
| Version | Description |
|---|---|
| 4.6 | Introduced. |