Payment Method Column in the Orders List
Adds a column to the admin orders screen showing how each order was paid, such as card, PayPal or bank transfer, without opening the order.
Opens WPIDE on
Code
$wpide_pm_column = function ( $columns ) {
$new = array();
foreach ( $columns as $key => $label ) {
$new[ $key ] = $label;
if ( 'order_status' === $key ) {
$new['wpide_payment'] = 'Payment';
}
}
return isset( $new['wpide_payment'] ) ? $new : $new + array( 'wpide_payment' => 'Payment' );
};
$wpide_pm_render = function ( $column, $order ) {
if ( 'wpide_payment' !== $column ) {
return;
}
$order = $order instanceof WC_Order ? $order : wc_get_order( $order );
echo $order ? esc_html( $order->get_payment_method_title() ? $order->get_payment_method_title() : '–' ) : '';
};
add_filter( 'manage_woocommerce_page_wc-orders_columns', $wpide_pm_column );
add_filter( 'manage_edit-shop_order_columns', $wpide_pm_column );
add_action( 'manage_woocommerce_page_wc-orders_custom_column', $wpide_pm_render, 10, 2 );
add_action( 'manage_shop_order_posts_custom_column', $wpide_pm_render, 10, 2 );
Notes
Works with both the HPOS orders screen and the legacy posts screen.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.