add custom columns to order list view
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
class Wiaas_Admin_Orders {
|
||||
|
||||
public static function init() {
|
||||
|
||||
add_filter( 'manage_edit-shop_order_columns', array(__CLASS__, 'add_additional_columns_to_orders_screen') );
|
||||
|
||||
add_action( 'manage_shop_order_posts_custom_column', array(__CLASS__, 'add_custom_columns_content') );
|
||||
}
|
||||
|
||||
public static function add_additional_columns_to_orders_screen( $columns ){
|
||||
|
||||
$new_columns = array();
|
||||
|
||||
$new_columns['reference'] = 'Location';
|
||||
$new_columns['commercial_lead'] = 'Commercial lead';
|
||||
$new_columns['customer'] = 'Customer';
|
||||
|
||||
$insertAfterColumn = 1;
|
||||
|
||||
return array_merge(array_slice($columns,0,$insertAfterColumn+1), $new_columns, array_slice($columns,$insertAfterColumn+1));
|
||||
|
||||
}
|
||||
|
||||
public static function add_custom_columns_content( $column ){
|
||||
|
||||
global $post;
|
||||
$column_content = '';
|
||||
|
||||
switch ($column){
|
||||
case 'reference':
|
||||
$column_content = Wiaas_Order::get_order_reference($post->ID);
|
||||
break;
|
||||
|
||||
case 'commercial_lead':
|
||||
$column_content = Wiaas_Order::get_order_commercial_lead_name($post->ID);
|
||||
break;
|
||||
|
||||
case 'customer':
|
||||
$column_content = Wiaas_Order::get_order_customer_full_name($post->ID);
|
||||
break;
|
||||
}
|
||||
|
||||
echo $column_content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Wiaas_Admin_Orders::init();
|
||||
Reference in New Issue
Block a user