eventsmanager

limit bookings to 1 ticket only

Jun 26th, 2015 (edited)
1,738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. /**
  2. * if ( $EM_Booking->booking_spaces > 2){ echo "Max of 2 ticket spacess is allowed"; }
  3. */
  4. function my_em_booking_ticket($result,$EM_Booking){
  5.  
  6. $ticket_count = 0;
  7. $mandatory = false;
  8.  
  9. foreach($EM_Booking->tickets_bookings as $EM_Ticket_Booking){
  10. if ( $EM_Ticket_Booking->get_ticket()->ticket_name == 'Gold' ){
  11. $mandatory = true;
  12. }
  13. $ticket_count++;
  14. }
  15.  
  16. // if ( $mandatory ){
  17. // if ( $ticket_count > 1 ){
  18. if ( $ticket_count > 1 || $mandatory ){
  19. $EM_Booking->add_error('Only one ticket is allowed per booking');
  20. $result = false;
  21. }
  22.  
  23. return $result;
  24. }
  25. add_filter('em_booking_validate','my_em_booking_ticket',100,2);
Advertisement
Add Comment
Please, Sign In to add comment