Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add Payment Method Column to Admin Orders
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
add_filter( 'manage_edit-shop_order_columns', 'wps_add_payment_method_column', 20 );
/**
* Add payment method column
*/
function wps_add_payment_method_column( $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_payment'] = __( 'Payment Method', 'my-textdomain' );
}
}
return $new_columns;
}
add_action( 'manage_shop_order_posts_custom_column', 'wps_add_payment_method_column_content' );
/**
* Add patment method comumn content
*/
function wps_add_payment_method_column_content( $column ) {
global $post;
if ( 'order_payment' === $column ) {
$order = wc_get_order( $post->ID );
echo $order->payment_method_title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.