Created
May 7, 2019 08:44
-
-
Save frankschrijvers/4a7901d612c62d953b4d027bf5668202 to your computer and use it in GitHub Desktop.
Add Payment Method Column to Admin Orders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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