Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankschrijvers/4a7901d612c62d953b4d027bf5668202 to your computer and use it in GitHub Desktop.
Save frankschrijvers/4a7901d612c62d953b4d027bf5668202 to your computer and use it in GitHub Desktop.
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