Skip to content

Instantly share code, notes, and snippets.

@cliffordp cliffordp/functions.php
Last active Mar 12, 2020

Embed
What would you like to do?
Event Tickets (v4.11.5+): Override the maximum quantity allowed to be purchased in a single Add To Cart action.
<?php
/**
* Event Tickets (v4.11.5+): Override the maximum quantity allowed to be purchased in a single Add To Cart action.
*
* @link https://gist.github.com/cliffordp/d5254fa306fa0c4ec1a27e73a083755e This snippet.
* @link https://theeventscalendar.com/knowledgebase/k/settings-overview-event-tickets-and-event-tickets-plus/#Ticket_settings Help article.
*
* @param Tribe__Tickets__Ticket_Object $ticket Ticket object.
* @param WP_Post $event Event post.
* @param int $ticket_id Raw ticket ID.
* @param int $available_at_a_time Max purchase quantity, as restricted by Max At A Time.
*
* @return int
*/
function cliff_change_max_qty_able_to_add_to_cart_at_a_time(
$available_at_a_time,
$ticket,
$event,
$ticket_id
) {
if ( 12345 === $event->ID ) {
$available_at_a_time = 180;
}
return $available_at_a_time;
}
add_filter( 'tribe_tickets_get_ticket_max_purchase', 'cliff_change_max_qty_able_to_add_to_cart_at_a_time', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.