Include Origin column for non-HPOS orders table

This commit is contained in:
Justin Palmer 2023-11-21 08:03:17 +01:00
parent 79fed9cac9
commit 07312708d1
No known key found for this signature in database
GPG Key ID: ACAB7C35AA2577AF
1 changed files with 16 additions and 18 deletions

View File

@ -400,25 +400,23 @@ class SourceAttributionController implements RegisterHooksInterface {
private function register_order_origin_column() {
$screen_id = $this->get_order_screen_id();
add_filter(
"manage_{$screen_id}_columns",
function( $columns ) {
$add_column = function( $columns ) {
$columns['origin'] = esc_html__( 'Origin', 'woocommerce' );
return $columns;
}
);
};
// HPOS and non-HPOS use different hooks.
add_filter( "manage_{$screen_id}_columns", $add_column );
add_filter( "manage_edit-{$screen_id}_columns", $add_column );
add_action(
"manage_{$screen_id}_custom_column",
function( $column_name, $order_id ) {
$display_column = function( $column_name, $order_id ) {
if ( 'origin' !== $column_name ) {
return;
}
$this->display_origin_column( $order_id );
},
10,
2
);
};
// HPOS and non-HPOS use different hooks.
add_action( "manage_{$screen_id}_custom_column", $display_column, 10, 2 );
add_action( "manage_{$screen_id}_posts_custom_column", $display_column, 10, 2 );
}
}