<?php
function my_em_bookings_table_cols_template_coupon($template, $EM_Bookings_Table){
$template['coupon_code'] = 'Coupon Name';
return $template;
}
add_action('em_bookings_table_cols_template', 'my_em_bookings_table_cols_template_coupon',10,2);
function my_em_custom_booking_form_cols_coupon($val, $col, $EM_Booking, $EM_Bookings_Table, $csv){
global $wpdb;
if( $col == 'coupon_code' ){
if ( $_REQUEST['view'] == 'attendees' || $_REQUEST['view'] == 'tickets' ){
$booking_meta = $wpdb->get_var('SELECT booking_meta FROM '.EM_BOOKINGS_TABLE.' WHERE booking_id='. absint($EM_Booking->booking_id) );
$booking_meta = unserialize( $booking_meta );
$val = $booking_meta['coupon']['coupon_code'];//$EM_Booking->booking_meta['coupon']['coupon_code'];
} else {
$val = $EM_Booking->booking_meta['coupon']['coupon_code'];
}
}
return $val;
}
add_filter('em_bookings_table_rows_col','my_em_custom_booking_form_cols_coupon', 10, 5);
Comments