0

I am working with the Wordpress Events Calendar & Event Tickets plugin.

I have created a category page for online events (the category is called 'online') and need to target the ticket so that it only allows one ticket to be purchased at a time.

I have found the following filter for my functions.php file from the Modern Tribe knowledge base, which works perfectly. But I need to be able to write this into a statement which would only target this specific category. Can anyone help please?

add_filter( 'tribe_tickets_get_ticket_max_purchase', function() { return 1; } );

John Paul
  • 87
  • 1
  • 8

1 Answers1

0

I solved this with following

function ticket_change_max_qty_able_to_add_to_cart_at_a_time(
    $available_at_a_time,
    $ticket,
    $event,
    $ticket_id
  ) {


    if (has_term(144, TribeEvents::TAXONOMY, $event->ID)) {
      $available_at_a_time = 1;
    }
   
    return $available_at_a_time;
  }
   
  add_filter( 'tribe_tickets_get_ticket_max_purchase', 'ticket_change_max_qty_able_to_add_to_cart_at_a_time', 10, 4 ); ```
John Paul
  • 87
  • 1
  • 8