Last active
March 12, 2020 19:22
-
-
Save cliffordp/d5254fa306fa0c4ec1a27e73a083755e to your computer and use it in GitHub Desktop.
Event Tickets (v4.11.5+): Override the maximum quantity allowed to be purchased in a single Add To Cart action.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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