Add customer billing country code column to admin orders list in WooCommerce

/**
 * Add new "Country" column to orders list
 */
add_filter( 'manage_edit-shop_order_columns', 'add_order_column_country', PHP_INT_MAX );
function add_order_column_country( $columns ) {
	$columns['country'] = 'Country';
	return $columns;
}
/**
 * Output "Country" column
 */
add_action( 'manage_shop_order_posts_custom_column', 'render_order_column_country', PHP_INT_MAX );
function render_order_column_country( $column ) {
	if ( 'country' != $column ) {
		return;
	}
	$order = wc_get_order( get_the_ID() );
	$country_code = $order->billing_country;
	echo $country_code;
}

No comments yet.

Leave a Reply