I need to show the product custom field in admin Orders page when a customer makes a purchase. Appreciate if anyone can help. :) I've already written some code and it works fine except the refunded orders.

My code is

// Add custom column headers:
add_action('woocommerce_admin_order_item_headers', 'my_woocommerce_admin_order_item_header');
function my_woocommerce_admin_order_item_header() {
    // set the column name
    $new_column_name = 'Location';

    // display the column name
    echo '<th>' . $new_column_name . '</th>';

// Add custom column values here
add_action('woocommerce_admin_order_item_values', 'my_woocommerce_admin_order_item_value', 10, 3);
function my_woocommerce_admin_order_item_value($_product, $product, $item, $item_id = null) {
    // get the post meta value from the associated product
    $value = get_post_meta($product['product_id'], 'item_notes', true);
    $value1 = get_post_meta($_product->post->ID, 'custom_field', 1);
    echo '<td>' . $value .'<br>'. $value1 .'</td>';

enter image description here

New contributor
user194601 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

user194601 is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.