我需要以下帮助:我想在wp-admin Woocommerce Orders表中添加一个预订状态列,但不是获取预订状态,而是获取订单状态。这是我在儿童主题的functions.php文件中使用的代码:
///将预订状态列添加到Woocommerce订单表
function add_bookingstatus_column( $columns ) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'order_status' === $column_name ) {
$new_columns['bookingorder_status'] = __( 'Booking Status', 'my-
textdomain' );
}
}
return $new_columns;
}
add_filter( 'manage_edit-shop_order_columns',
'add_bookingstatus_column' );
function add_bookingstatus_column_content( $column ) {
global $post;
if ( 'bookingorder_status' === $column ) {
$bookingorder = wc_get_order( $post->ID );
echo wc_bookings_get_status_label( $bookingorder->get_status() );
}
}
add_action( 'manage_shop_order_posts_custom_column',
'add_bookingstatus_column_content' );