2014-07-06 69 views

回答

1

您可以覆蓋模板 - >訂單 - >order-detals.php來編輯查看訂單頁面。只需在以下$item_meta->display();,您將在查看訂單頁面中獲得一個包含自定義字段值的數組。現在從數組中獲取您的自定義字段數據。

或者 使用此查詢下面$item_meta->display();

$pid=$item_meta->meta['_product_id'][0];
$custom_val=$wpdb->get_var("select meta_value from wp_postmeta where post_id = {$pid} AND meta_key='AWB'"); echo "Air Waybill: ".$custom_val;

注:AWB =自定義字段名稱

+0

謝謝@nishant但我不能找到該陣列的自定義字段數據 – vincmeister

+0

檢查我的編輯答案。 – nishant

+0

如果您的問題已解決,請將其標記爲已解決。 – nishant

2

重寫訂單details.php是不好的做法,因爲當你更新woocommerce版本,它重置您在woocommerce核心文件中所做的所有更改。更好的選擇是使用主題的functions.php顯示自定義字段中查看訂單頁面是這樣的:

function action_woocommerce_order_details_after_customer_details($order) { 

    echo get_post_meta($order->id, 'awb', true); 
} 

add_action('woocommerce_order_details_after_customer_details', 'action_woocommerce_order_details_after_customer_details', 10, 1); 
相關問題