Back-end: How to add custom column on shipments’ table?

add-column

Add table header

add_filter( 'default_wpcargo_columns', 'custom_columns' );
function custom_columns( $columns ) {
	$custom_column = array( 'custom_column' => esc_html__( 'Custom Column', 'wpcargo-branches' ) );
	$position = count( $columns ) -1 ;
	$columns = array_slice($columns, 0, $position, true) + $custom_column + array_slice( $columns, $position, count($columns) - 1, true );
	return $columns;
}

Add table data aligned on the header created above

Note: Change meta_key to the meta key of the shipment you want to display.

add_action( 'manage_wpcargo_shipment_posts_custom_column', 'custom_column_data', 10, 2 );
function custom_column_data( $column, $post_id ) {
	if( $column == 'custom_column' ){
		echo get_post_meta( $post_id, 'meta_key', true );
	}
}

Add sortable column function on your custom column

add_filter( 'manage_edit-wpcargo_shipment_sortable_columns', 'custom_sortable_columns' );
function custom_sortable_columns( $columns ) {
	$columns['custom_column'] = 'custom_column';	
	return $columns;
}
0
    0
    Your Cart
    Your cart is emptyReturn to Shop