Das war removed aus Leistungsgründen zu haben scheint, aber Sie den Code aussehen könnte, dass es wurde entfernt, und fügen Sie über den manage_shop_order_posts_columns
Filter und manage_shop_order_posts_custom_column
Aktion zurück.
/**
* Modify the custom columns for orders.
* @param array $columns
* @return array
*/
function so_43719068_shop_order_columns($columns) {
// the new column as an array for subsequent array manip
$new_column = array('order_items' => __('Purchased', 'your-plugin'));
$insert_after = 'order_title';
// insert after specified column
if(isset($columns[ $insert_after ])){
// find the "title" column
$index = array_search($insert_after, array_keys($columns));
// reform the array
$columns = array_merge(array_slice($columns, 0, $index + 1, true), $new_column, array_slice($columns, $index, count($columns) - $index, true));
// or add to end
} else {
$columns = array_merge($columns, $new_column);
}
return $columns;
}
add_filter('manage_shop_order_posts_columns', 'so_43719068_shop_order_columns', 20);
/**
* Output custom columns for orders.
* @param string $column
* @param int $post_id
*/
function so_43719068_render_shop_order_columns($column, $post_id) {
global $the_order;
if (empty($the_order) || $the_order->get_id() !== $post_id) {
$the_order = wc_get_order($post_id);
}
switch ($column) :
case 'order_items' :
/* translators: %d: order items count */
echo '<a href="#" class="show_order_items">' . apply_filters('woocommerce_admin_order_item_count', sprintf(_n('%d item', '%d items', $the_order->get_item_count(), 'woocommerce'), $the_order->get_item_count()), $the_order) . '</a>';
if (sizeof($the_order->get_items()) > 0) {
echo '<table class="show_order_items" cellspacing="0">';
foreach ($the_order->get_items() as $item) {
$product = apply_filters('woocommerce_order_item_product', $item->get_product(), $item);
$item_meta_html = wc_display_item_meta($item, array('echo' => false));
?>
<tr class="<?php echo apply_filters('woocommerce_admin_order_item_class', '', $item, $the_order); ?>">
<td class="qty"><?php echo esc_html($item->get_quantity()); ?></td>
<td class="name">
<?php if ($product) : ?>
<?php echo (wc_product_sku_enabled() && $product->get_sku()) ? $product->get_sku() . ' - ' : ''; ?><a href="<?php echo get_edit_post_link($product->get_id()); ?>"><?php echo apply_filters('woocommerce_order_item_name', $item->get_name(), $item, false); ?></a>
<?php else : ?>
<?php echo apply_filters('woocommerce_order_item_name', $item->get_name(), $item, false); ?>
<?php endif; ?>
<?php if (! empty($item_meta_html)) : ?>
<?php echo wc_help_tip($item_meta_html); ?>
<?php endif; ?>
</td>
</tr>
<?php
}
echo '</table>';
} else echo '–';
break;
endswitch;
}
add_action('manage_shop_order_posts_custom_column', 'so_43719068_render_shop_order_columns', 10, 2);