Advertisement
eventsmanager

Ticket spaces bookings table column

Apr 12th, 2016
1,057
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2. /*
  3.  This snippet will add a custom column to the bookings table, which shows the number of ticket spaces booked when viewing a booking table with the scope of a single ticket type.
  4.  
  5.  For help with adding this for your site, see here - http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
  6.  */
  7.  
  8. /**
  9.  * Adds columns in the bookings tables
  10.  * @param array $template
  11.  * @return string
  12.  */
  13. function my_em_bookings_table_cols_template_ticket_spaces($template){
  14.     $template['ticket_spaces'] = 'Ticket Spaces';
  15.     return $template;
  16. }
  17. add_action('em_bookings_table_cols_template', 'my_em_bookings_table_cols_template_ticket_spaces',10,1);
  18.  
  19. /**
  20.  * @param string $val
  21.  * @param string $col
  22.  * @param EM_Booking $EM_Booking
  23.  */
  24. function my_em_custom_booking_form_cols_ticket_spaces($val, $EM_Booking){
  25.     global $wpdb;
  26.     $spaces = $EM_Booking->get_spaces();
  27.     if( !empty($_REQUEST['ticket_id']) ){
  28.         foreach( $EM_Booking->get_tickets_bookings() as $EM_Ticket_Booking ){ /* @var $EM_Ticket_Booking EM_Ticket_Booking */
  29.             if( $EM_Ticket_Booking->ticket_id == $_REQUEST['ticket_id'] ){
  30.                 $spaces = $EM_Ticket_Booking->get_spaces();
  31.             }
  32.         }
  33.     }
  34.     return absint($spaces);
  35. }
  36. add_filter('em_bookings_table_rows_col_ticket_spaces','my_em_custom_booking_form_cols_ticket_spaces', 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement