2

I'm trying to add a column product list to admin order page.
Something like on the image:

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399

2 Answers2

1

Current version of WooCommerce, there's no easy way.

This is the code responsible for that part.

    <tbody id="order_line_items">
    <?php
        foreach ( $line_items as $item_id => $item ) {
            do_action( 'woocommerce_before_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );

            include( 'html-order-item.php' );

            do_action( 'woocommerce_order_item_' . $item->get_type() . '_html', $item_id, $item, $order );
        }
        do_action( 'woocommerce_admin_order_items_after_line_items', $order->get_id() );
    ?>
    </tbody>

Specifically this line: include( 'html-order-item.php' );. Of which if you take a look at the contents of html-order-item.php, there's no hook for you to able to add another td.

What I can suggest though is you use one of the two actions above inside foreach loop. Use it to place a td tag with your data. Then use jQuery to transfer that td to where it should be.

Reigel Gallarde
  • 64,198
  • 21
  • 121
  • 139
0

You can try this code

add_action('woocommerce_admin_order_item_headers', 'my_woocommerce_admin_order_item_headers');
function my_woocommerce_admin_order_item_headers() {
    $column_name = 'TEXT';
    echo '<th>' . $column_name . '</th>';
}

add_action('woocommerce_admin_order_item_values', 'my_woocommerce_admin_order_item_values', 10, 3);
function my_woocommerce_admin_order_item_values($_product, $item, $item_id = null) {

    $value = 50;
if($item['type']=="line_item")
     echo '<td>' . $value . '</td>';
}
Jinesh
  • 1,554
  • 10
  • 15