Created
February 25, 2022 05:43
-
-
Save jhimross/dea7219af703f01952a4e37962962249 to your computer and use it in GitHub Desktop.
Add Payment Method in Order Column
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
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