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.

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


Top ↑

Parameters

$ticket_id

(int|string) (Required) Ticket from which to fetch purchase max.


Top ↑

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.


Top ↑

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 );
	}

Top ↑

Changelog

Changelog
Version Description
4.8.1
4.11.5 Introduced.