在主题函数中添加以下代码。php
function action_woocommerce_admin_order_item_headers( )
{ ?>
<th class="item sortable" colspan="2" data-sort="string-ins"><?php _e( \'Item category\', \'woocommerce\' ); ?></th>
<?php
};
// define the woocommerce_admin_order_item_values callback
function action_woocommerce_admin_order_item_values( $_product, $item, $item_id )
{ ?>
<td class="name" colspan="2" >
<?php
$termsp = get_the_terms( $_product->id, \'product_cat\' );
if(!empty($termsp)){
foreach ($termsp as $term) {
$_categoryid = $term->term_id;
if( $term = get_term_by( \'id\', $_categoryid, \'product_cat\' ) ){
echo $term->name .\', \';
}
} } ?>
</td>
<?php
};
// add the action
add_action( \'woocommerce_admin_order_item_values\', \'action_woocommerce_admin_order_item_values\', 10, 3 );
add_action( \'woocommerce_admin_order_item_headers\', \'action_woocommerce_admin_order_item_headers\', 10, 0 );