Hi Stephen
I want to cap users to be only able tp purchase 2x tickets for each event.
I have played with the bookings and found I can cap the amount of tickets total and per ticket type but not for user.
Is this possible ? My tickets are only available to users that are logged in.
Thanks
Jody

Jody Brown
Hi Jody,
There’s an tutorial on how to limit bookings to one ticket per user, which can be adapted to allow two tickets. (For just check if a user has made a prior booking you can use the function eo_user_has_bookings()
(see codex).
For checking if the number of tickets purchased exceeds 2, it is slightly more involed:
//1. Get relevant bookings associated with the user
//You'll need to provide the $event_id (and $occurrence_id) if applicable. and provide the statuses to check
$bookings = eo_get_bookings( array(
'bookee_id' => get_current_user_id(),
'event_id' => $event_id,
'occurrence_id' => $occurrence_id, //Remove if not selling by date
'status'=> $status, //"any" for any status. Or array( 'confirmed', 'other-custom-status' ),
'fields'=>'ids'
) );
//2. Count the tickets in these bookings
$ticket_count = 0;
if( $bookings ){
foreach( $booking as $booking_id ){
$ticket_count += eo_get_booking_meta( $booking_id, 'ticket_quantity' );
}
}
//You can then check $ticket_count.
**Please note the above is untested*

Stephen Harris
Great thanks again Stephen
They have just changed the plan on me and only want one per user
So i used the link you shared and made a plugin works perfect thanks 🙂

Jody Brown