Refunded Amount Column in the Orders List
Shows how much has been refunded on each order in the admin orders list, so partial refunds are visible without opening every order.
Opens WPIDE on
Code
$wpide_refund_column = function ( $columns ) {
$columns['wpide_refunded'] = 'Refunded';
return $columns;
};
$wpide_refund_render = function ( $column, $order ) {
if ( 'wpide_refunded' !== $column ) {
return;
}
$order = $order instanceof WC_Order ? $order : wc_get_order( $order );
$refunded = $order ? (float) $order->get_total_refunded() : 0;
echo $refunded > 0 ? wp_kses_post( '<span style="color:#b32d2e">' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . '</span>' ) : '–';
};
add_filter( 'manage_woocommerce_page_wc-orders_columns', $wpide_refund_column );
add_filter( 'manage_edit-shop_order_columns', $wpide_refund_column );
add_action( 'manage_woocommerce_page_wc-orders_custom_column', $wpide_refund_render, 10, 2 );
add_action( 'manage_shop_order_posts_custom_column', $wpide_refund_render, 10, 2 );
Notes
Orders without refunds show a dash.
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.