2

Attempting to display the admin-defined title/name of the method, not the method itself.

Looks like I need code similar to this (minus the 2nd column):
Add columns in admin order list on woocommerce 3.3
and the title fetching portion of this:
Add an image on Woocommerce payment method title

Or is there an easier way? I need this because using a plugin that provides up to 10 duplicate versions of the Bank Transfers payment method, and each is named to represent a company's departmental budget. Orders get approved and billed by these budgets.

LoicTheAztec
  • 207,510
  • 22
  • 296
  • 340
Scott
  • 55
  • 1
  • 6

1 Answers1

1

To add the payment method title in a new column on admin order list, try the following:

// Add a new custom column to admin order list
add_filter( 'manage_edit-shop_order_columns', 'add_payment_shop_order_column',11);
function add_payment_shop_order_column($columns) {
    $reordered_columns = array();

    foreach( $columns as $key => $column){
        $reordered_columns[$key] = $column;
        if( $key ==  'order_number' ){
            $reordered_columns['payment_method'] = __( 'Payment','Woocommerce');
        }
    }
    return $reordered_columns;
}

// The data of the new custom column in admin order list
add_action( 'manage_shop_order_posts_custom_column' , 'orders_list_column_payment_title', 10, 2 );
function orders_list_column_payment_title( $column, $post_id ){
    if( 'payment_method' === $column ){
        $payment_title = get_post_meta( $post_id, '_payment_method_title', true );
        if( ! empty($payment_title) )
            echo $payment_title;
    }
}

Code goes in functions.php file of your active child theme (or active theme). It should works.

LoicTheAztec
  • 207,510
  • 22
  • 296
  • 340