Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- 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.
- For help with adding this for your site, see here - http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
- */
- /**
- * Adds columns in the bookings tables
- * @param array $template
- * @return string
- */
- function my_em_bookings_table_cols_template_ticket_spaces($template){
- $template['ticket_spaces'] = 'Ticket Spaces';
- return $template;
- }
- add_action('em_bookings_table_cols_template', 'my_em_bookings_table_cols_template_ticket_spaces',10,1);
- /**
- * @param string $val
- * @param string $col
- * @param EM_Booking $EM_Booking
- */
- function my_em_custom_booking_form_cols_ticket_spaces($val, $EM_Booking){
- global $wpdb;
- $spaces = $EM_Booking->get_spaces();
- if( !empty($_REQUEST['ticket_id']) ){
- foreach( $EM_Booking->get_tickets_bookings() as $EM_Ticket_Booking ){ /* @var $EM_Ticket_Booking EM_Ticket_Booking */
- if( $EM_Ticket_Booking->ticket_id == $_REQUEST['ticket_id'] ){
- $spaces = $EM_Ticket_Booking->get_spaces();
- }
- }
- }
- return absint($spaces);
- }
- 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