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.

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.


Top ↑

Return

(int)


Top ↑

Source

File: src/Tribe/Tickets_Handler.php


Top ↑

Changelog

Changelog
Version Description
4.11.5 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Andras Guseo

    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:

    • ID
    • name
    • description
    • show_description
    • price
    • capacity
    • regular_price
    • on_sale
    • admin_link
    • report_link
    • frontend_link
    • provider_class
    • sku
    • iac
    • price_suffix
    • menu_order