I'm adding the following custom columns and they both appear:
function add_order_new_column_header( $columns ) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'order_total' === $column_name ) {
$new_columns['order_shipping'] = __( 'Tarnemeetod', 'my-textdomain' );
$new_columns['order_payment'] = __( 'Maksemeetod', 'my-textdomain' );
}
}
return $new_columns;
Then I'm adding the following to generate data:
add_filter( 'manage_edit-shop_order_columns', 'add_order_new_column_header', 20);
add_action( 'manage_shop_order_posts_custom_column', 'add_wc_order_admin_list_column_content' );
function add_wc_order_admin_list_column_content( $column ) {
global $post;
if ( 'order_shipping' === $column ) {
$order = wc_get_order( $post->ID );
echo $order->get_shipping_method();
if ( 'order_payment' === $column ) {
$order = wc_get_order( $post->ID );
echo $order->get_payment_method_title();
}
}
}
order_shipping is showing correct shipping method, but order_payment is empty. I'm not using multiple languages on the site. WooCommerce 4.1.1, PHP 7.3.19
view from WooCommerce orders admin panel:
I've tried both get_payment_method and get_payment_method_list. I have orders with BACS mostly and a few Cash on Pickup which is disabled for now. What am I missing here?