added custom columns but some parts are not working

I’m trying to add custom columns to ‘Property List(custom post-type)’ in admin page.
custom columns are that

Total booking number
Refunded number

so, here is my code which works only ‘Total booking number’. what’s wrong with the code?
please help me out!

add_filter( ‘manage_edit-estate_property_columns’, ‘wpestate_my_columns’ );

if( !function_exists(‘wpestate_my_columns’) ):
function wpestate_my_columns( $columns ) {
$slice=array_slice($columns,2,2);
unset( $columns[‘comments’] );
unset( $slice[‘comments’] );
$splice=array_splice($columns, 2);
$columns[‘estate_image’] = esc_html__( ‘Image’,’wpestate’);
$columns[‘estate_action’] = esc_html__( ‘Action’,’wpestate’);
$columns[‘estate_category’] = esc_html__( ‘Category’,’wpestate’);
$columns[‘estate_autor’] = esc_html__( ‘User’,’wpestate’);
$columns[‘estate_status’] = esc_html__( ‘Status’,’wpestate’);
$columns[‘estate_price’] = esc_html__( ‘Price per night’,’wpestate’);
$columns[‘estate_booking_total’] = esc_html__( ‘Total Booking’,’wpestate’);
$columns[‘estate_booking_refuned’] = esc_html__( ‘Refuned’,’wpestate’);
return array_merge($columns,array_reverse($slice));
}
endif; // end wpestate_my_columns

add_action( ‘manage_posts_custom_column’, ‘wpestate_populate_columns’ );
if( !function_exists(‘wpestate_populate_columns’) ):
function wpestate_populate_columns( $column ) {
$the_id=get_the_ID();
if ( ‘estate_image’ == $column ) {
echo get_the_post_thumbnail($the_id,’wpestate_user_thumb’);
}

if ( ‘estate_status’ == $column ) {
$estate_status = get_post_status(get_the_ID());
if($estate_status==’publish’){
echo esc_html__( ‘published’,’wpestate’);
}else{
echo $estate_status;
}

$pay_status = get_post_meta(get_the_ID(), ‘pay_status’, true);
if($pay_status!=”){
echo ” | “.$pay_status;
}

}

if ( ‘estate_autor’ == $column ) {
$user_id=wpsestate_get_author(get_the_ID());
$estate_autor = get_the_author_meta(‘display_name’);;
echo ‘<a href=”‘.get_edit_user_link($user_id).'” >’. $estate_autor.'</a>’;
}

if ( ‘estate_action’ == $column ) {
$estate_action = get_the_term_list( get_the_ID(), ‘property_action_category’, ”, ‘, ‘, ”);
echo $estate_action;
}
elseif ( ‘estate_category’ == $column ) {
$estate_category = get_the_term_list( get_the_ID(), ‘property_category’, ”, ‘, ‘, ”);
echo $estate_category ;
}

if ( ‘estate_price’ == $column ) {
$currency = esc_html( get_option(‘wp_estate_currency_label_main’, ”) );
$where_currency = esc_html( get_option(‘wp_estate_where_currency_symbol’, ”) );
wpestate_show_price(get_the_ID(),$currency,$where_currency,0);
}
if ( ‘estate_booking_total’ == $column ) {
$args_bnum1 = array(
‘post_type’ => ‘wpestate_booking’,
‘post_status’ => ‘publish’,
‘meta_query’ => array(
‘relation’ => ‘AND’,
array(
‘key’ => ‘booking_id’,
‘value’ => $the_id
),
array(
‘key’ => ‘booking_status_full’,
‘value’ => ‘confirmed’
),
array(
‘key’ => ‘booking_status’,
‘value’ => ‘refunded’,
‘compare’ => ‘!=’
)
)
);

$my_query = new WP_Query($args_bnum1);
$booking_num_count_total = $my_query->found_posts;
wp_reset_query();
echo $booking_num_count_total;
}
if ( ‘estate_booking_refuned’ == $column ) {
$args_bnum1 = array(
‘post_type’ => ‘wpestate_booking’,
‘post_status’ => ‘publish’,
‘meta_query’ => array(
‘relation’ => ‘AND’,
array(
‘key’ => ‘booking_id’,
‘value’ => $the_id
),
array(
‘key’ => ‘booking_status_full’,
‘value’ => ‘confirmed’
),
array(
‘key’ => ‘booking_status’,
‘value’ => ‘refunded’
)
)
);

$my_query = new WP_Query($args_bnum1);
$booking_num_count_refuned = $my_query->found_posts;
wp_reset_query();
echo $booking_num_count_refuned;
}

}
endif; // end wpestate_populate_columns

Read more here:: added custom columns but some parts are not working

Leave a Reply

Your email address will not be published. Required fields are marked *