Tribe__Tickets__Tickets_Handler::get_ticket_max_purchase( int|string $ticket_id )
Gets the maximum quantity able to be purchased in a single Add to Cart action for a given ticket.
Contents
If a ticket’s actual ticket stock available is Unlimited, this will return the maximum allowed to be purchased in a single action (i.e. always zero or greater).
See also
- Tribe__Tickets__Ticket_Object::available(): The actual ticket stock available, allowing -1 for Unlimited.
Parameters
- $ticket_id
-
(int|string) (Required) Ticket from which to fetch purchase max.
Return
(int) A non-negative integer of how many tickets can be purchased in a single "add to cart" type of action (allows zero but not -1 for Unlimited). If oversold, will be corrected to zero.
Source
File: src/Tribe/Tickets_Handler.php
public function get_ticket_max_purchase( $ticket_id ) {
$event_id = tribe_events_get_ticket_event( $ticket_id );
$provider = tribe_tickets_get_ticket_provider( $ticket_id );
$ticket = $provider->get_ticket( $event_id, $ticket_id );
$available = $ticket->available();
/**
* Allows filtering of the max input for purchase of this one ticket
*
* @since 4.8.1
*
* @param int $available Max Purchase number
* @param Tribe__Tickets__Ticket_Object $ticket Ticket Object
* @param int $event_id Event ID
* @param int $ticket_id Ticket Raw ID
*
*/
return apply_filters( 'tribe_tickets_get_ticket_max_purchase', $available, $ticket, $event_id, $ticket_id );
}
Changelog
| Version | Description |
|---|---|
| 4.8.1 | |
| 4.11.5 | Introduced. |