2015-02-23 79 views
1

找不到可以將示例列添加到後臺訂單列表的工作解決方案。已經嘗試過這些(子主題的functions.php文件內):如何在Woocommerce上添加專欄 - >訂單後臺頁面

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,3.7.3阿瓦達索與兒童主題啓用,重力窗體22年8月1日+幾WooCommerce插件和其他插件。

+0

任何幫助將不勝感激...... – 2015-02-23 10:42:20

+0

它似乎我做錯了什麼,因爲該代碼是隻能生成白色屏幕死亡。 – 2015-02-23 11:28:56

+0

即使很小的消化,將不勝感激。也許我應該提供一些其他信息? – 2015-02-23 15:59:02

回答

0

好了 - Woocommerce更新解決了它。

相關問題