eventsmanager

Ticket spaces bookings table column

Apr 12th, 2016
414
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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);
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×