![](/img/trans.png)
[英]Display back Order Notes in Admin orders list on WooCommerce 3.3
[英]Add columns in admin order list on woocommerce 3.3
相關信息: 在WooCommerce后端的管理訂單列表中添加列
是否可以只在管理訂單列表中添加一個新列。 對於本列my-column1
的內容,我想有2個自定義字段,例如:
$my_var_one = get_post_meta( $post_id, '_the_meta_key1', true );
$my_var_two = get_post_meta( $post_id, '_the_meta_key2', true );
最后,是否可以將新列order_number
在order_number
?
任何幫助表示贊賞。
已更新 -可以通過以下方式完成:
// ADDING 1 NEW COLUMNS WITH THEIR TITLES
add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column',11);
function custom_shop_order_column($columns)
{
$reordered_columns = array();
foreach( $columns as $key => $column){
$reordered_columns[$key] = $column;
if( $key == 'order_number' ){
$reordered_columns['my-column1'] = __( 'Title1','theme_slug');
}
}
return $reordered_columns;
}
// Adding the data for the additional column (example)
add_action( 'manage_shop_order_posts_custom_column' , 'custom_orders_list_column_content', 10, 2 );
function custom_orders_list_column_content( $column, $post_id )
{
if( 'my-column1' == $column )
{
// Get custom post meta data 1
$my_var_one = get_post_meta( $post_id, '_the_meta_key1', true );
if(!empty($my_var_one))
echo $my_var_one;
// Get custom post meta data 2
$my_var_two = get_post_meta( $post_id, '_the_meta_key2', true );
if(!empty($my_var_two))
echo $my_var_two;
// Testing (to be removed) - Empty value case
if( empty($my_var_one) && empty($my_var_two) )
echo '<small>(<em>no value</em>)</small>';
}
}
其他功能保持不變...
代碼進入您的活動子主題(或活動主題)的function.php文件中。 經過測試和工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.