apply_filters( 'tribe_tickets_get_ticket_default_max_purchase', int $default_max , Tribe__Tickets__Ticket_Object $ticket )
Cap the amount of tickets able to be purchased at a single time (single “add to cart” action) for sanity and performance reasons.
Contents
Anything less than 1 will be ignored and reset to the default.
Parameters
- $default_max
-
(int) Maximum quantity allowed at one time (only applicable if the ticket stock available is greater).
- $ticket
-
(Tribe__Tickets__Ticket_Object) Ticket object.
Return
(int)
Source
Changelog
| Version | Description |
|---|---|
| 4.11.5 | Introduced. |
To limit the number of tickets that can be added to the cart at a time to 1:
add_filter( 'tribe_tickets_get_ticket_default_max_purchase', function() { return 1; } );It is also possible to limit this functionality based on ticket properties. For example ticket ID.
add_filter( 'tribe_tickets_get_ticket_default_max_purchase', 'my_max', 10, 2 ); function my_max ( $default_max, $ticket ) { if ( $ticket->ID == 9783 ) { return 1; } return $default_max; }Some ticket properties that can be used: