Hi Stephen,
My client would like to limit a maximum number of tickets per booking (across all classes of tickets on an event and occurrence). For instance, if there was a Pixies gig on next week, they’d want to be able to stop a scalper from going and buying 100 tickets.
This thread get close – but seems to be slightly more complex than my example.
Any ideas how I might do this? Or should I get to work adapting your solution to Henning’s problem?
Best wishes,
Andrew

Andrew Shankie
That thread indicates how to add a custom property to tickets. I don’t think that’s necessary here, as your limit on bookings is probably fixed and global.
I think this tutorial gets you most of the way: http://wp-event-organiser.com/blog/tutorial/limit-bookings-to-one-ticket/ (changing 1 to 100).
The problem here is that that tutorial will prevent a second booking for the same event/occurrence. In this case, if someone made a booking of 50, then you’d be happy to let them make a second booking of up to 49.
To do that, you’d want to replace the following in the tutorial:
/* Throw error if user has previously made a booking for this event */
if( eo_user_has_bookings( get_current_user_id(), $post_id, $occurrence_id ) ){
//This error will prevent the booking from being processed, and display the given error message
$errors->add( 'previous_booking', 'You have already made a booking for this event.' );
}
with something a bit more complex:
$previous_bookings = eo_get_bookings( array(
'bookee_id' => get_current_user_id(),
'event_id' => $event_id,
'occurrence_id' => $occurrence_id,
'status' => 'any',
'fields' => 'ids'
));
$previous_tickets = 0;
if( $prevous_bookings ){
foreach( $previous_bookings as $p_booking_id ) {
$previous_tickets += eo_get_booking_meta( $p_booking_id, 'ticket_quantity' );
}
}
$total_qty = array_sum( $tickets )
if( $total_qty + $previous_tickets > 100 ){
$errors->add( 'previous_booking', 'You have already made a booking for this event.' );
}
This code is untested, but it should at least get you most of the way there.

Stephen Harris
Hi Stephen,
That’s great. Thanks ever so much. I’ll drop it in and let you know if I run into any troubles.
Cheers,
Andrew

Andrew Shankie