找不到将示例列添加到后端订单列表的工作解决方案。已经尝试过这些(在儿童主题的functions.php中):
add_filter('manage_edit-shop_order_columns', 'extra_column');
function extra_column($columns) {
$columns['title'] = 'Product-x';
return $columns;
}
add_filter( 'manage_edit-shop_order_columns', 'MY_COLUMNS_FUNCTION' );
function MY_COLUMNS_FUNCTION($columns){
$new_columns = (is_array($columns)) ? $columns : array();
unset( $new_columns['order_actions'] );
//edit this for you column(s)
//all of your columns will be added before the actions column
$new_columns['MY_COLUMN_ID_1'] = 'MY_COLUMN_1_TITLE';
// $new_columns['MY_COLUMN_ID_2'] = 'MY_COLUMN_2_TITLE';
//stop editing
$new_columns['order_actions'] = $columns['order_actions'];
return $new_columns;
}
add_action( 'manage_shop_order_posts_custom_column', 'MY_COLUMNS_VALUES_FUNCTION', 2 );
function MY_COLUMNS_VALUES_FUNCTION($column){
global $post;
$data = get_post_meta( $post->ID );
//start editing, I was saving my fields for the orders as custom post meta
//if you did the same, follow this code
if ( $column == 'MY_COLUMN_ID_1' ) {
echo (isset($data['MY_COLUMN_1_POST_META_ID']) ? $data['MY_COLUMN_1_POST_META_ID'] : '');
}
if ( $column == 'MY_COLUMN_ID_2' ) {
echo (isset($data['MY_COLUMN_2_POST_META_ID']) ? $data['MY_COLUMN_2_POST_META_ID'] : '');
}
}
add_filter( 'manage_edit-shop_order_columns', 'imarcon_set_custom_column_order_columns');
function imarcon_set_custom_column_order_columns($columns) {
// global $woocommerce;
$nieuwearray = array();
foreach($columns as $key => $title) {
if ($key=='billing_address') // in front of the Billing column
$nieuwearray['order_producten'] = __( 'Products', 'woocommerce' );
$nieuwearray[$key] = $title;
}
return $nieuwearray ;
}
我正在使用WP 4.1.1,Avada 3.7.3启用了儿童主题,Gravity Forms 1.8.22 +少数WooCommerce插件和其他插件。
答案 0 :(得分:0)
好的,Woocommerce更新解决了它。