下面是與2個自定義函數掛鉤的方法。第一個使用標題創建列,第二個使用產品數據填充列。但是你需要在第二個函數中設置正確的對應的數據。
這裏是代碼:
// ADDING A CUSTOM COLUMN TITLE TO ADMIN PRODUCTS LIST
add_filter('manage_edit-product_columns', 'custom_product_column',11);
function custom_product_column($columns)
{
//add columns
$columns['delivery'] = __('Delivery time','woocommerce'); // title
return $columns;
}
// ADDING THE DATA FOR EACH PRODUCTS BY COLUMN (EXAMPLE)
add_action('manage_product_posts_custom_column' , 'custom_product_list_column_content', 10, 2);
function custom_product_list_column_content($column, $product_id)
{
global $post;
// HERE get the data from your custom field (set the correct meta key below)
$delivery_time = get_post_meta($product_id, '_delivery_time', true);
switch ($column)
{
case 'delivery' :
echo $delivery_time; // display the data
break;
}
}
代碼放在您的活動子主題(或主題)的function.php文件或也以任何插件文件。
經過測試和工作。
如何得到正確的meta_key毛坯:
要找到對應「交貨期」正確meta_key
蛞蝓,如果您需要讓搜索數據庫中的使用PhpMyAdmin。你將不得不這樣搜索delivery
術語wp_postmeta
表:
然後你會得到這樣的結果(這裏有一個假的蛞蝓只有1線):
所以,現在你應該能夠得到正確的蛞蝓名(LI柯這個假 「_delivery_date」 之一) ...
相關答案(訂單):Add custom columns to admin orders list in WooCommerce backend
是的,可能的,但是從那裏這個交貨期數據會來嗎?產品元? – Alice