I'm trying to add a column product list to admin order page.
Something like on the image:
Asked
Active
Viewed 954 times
2
LoicTheAztec
- 207,510
- 22
- 296
- 340
user3013821
- 25
- 4
2 Answers
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
- 62,834
- 21
- 119
- 135
-
It's not a problem for me to edit the plugin core files, so I'll do that in html-order-item.php Thanks – user3013821 Mar 27 '18 at 08:37
-
2@user3013821 that should be a problem and at all cost must be avoided.. but it's your call.. good luck. – Reigel Mar 27 '18 at 08:54
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,536
- 10
- 15