Add ID Column to Payment Methods Table
Sometimes when you work with payment gateways on your website, you need to know their IDs (slugs). In this tutorial I show how to add a column to the payment gateways table in WooCommerce settings using a small piece of code.
Here is our result:

In order to achieve that all you have to do is to add this code to your current or child theme functions.php
.
add_filter( 'woocommerce_payment_gateways_setting_columns', 'rudr_add_payment_method_column' );
function rudr_add_payment_method_column( $default_columns ) {
$default_columns = array_slice( $default_columns, 0, 2 ) + array( 'id' => 'ID' ) + array_slice( $default_columns, 2, 3 );
return $default_columns;
}
// woocommerce_payment_gateways_setting_column_{COLUMN ID}
add_action( 'woocommerce_payment_gateways_setting_column_id', 'rudr_populate_gateway_column' );
function rudr_populate_gateway_column( $gateway ) {
echo '<td style="width:10%">' . $gateway->id . '</td>';
}
What else is in $gateway
object? You can try to print_r()
it in order to find out.
echo '<td>' . print_r( $gateway, true ) . '</td>';
If you need WooCommerce custom payment gateway plugin development, please feel free to contact me.

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
Very great help.