eventsmanager

Custom "Coupon Code" column in the bookings summary

Jun 27th, 2025
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. function my_em_bookings_table_cols_template_coupon($template, $EM_Bookings_Table){
  4. $template['coupon_code'] = 'Coupon Name';
  5. return $template;
  6. }
  7. add_action('em_bookings_table_cols_template', 'my_em_bookings_table_cols_template_coupon',10,2);
  8.  
  9. function my_em_custom_booking_form_cols_coupon($val, $col, $EM_Booking, $EM_Bookings_Table, $csv){
  10. global $wpdb;
  11. if( $col == 'coupon_code' ){
  12. if ( $_REQUEST['view'] == 'attendees' || $_REQUEST['view'] == 'tickets' ){
  13. $booking_meta = $wpdb->get_var('SELECT booking_meta FROM '.EM_BOOKINGS_TABLE.' WHERE booking_id='. absint($EM_Booking->booking_id) );
  14. $booking_meta = unserialize( $booking_meta );
  15. $val = $booking_meta['coupon']['coupon_code'];//$EM_Booking->booking_meta['coupon']['coupon_code'];
  16. } else {
  17. $val = $EM_Booking->booking_meta['coupon']['coupon_code'];
  18. }
  19. }
  20.  
  21. return $val;
  22. }
  23. add_filter('em_bookings_table_rows_col','my_em_custom_booking_form_cols_coupon', 10, 5);
Advertisement
Add Comment
Please, Sign In to add comment