1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
add_filter('manage_edit-shop_order_columns', 'misha_order_items_column' ); function misha_order_items_column( $order_columns ) { $order_columns['order_products'] = "Purchased products"; return $order_columns; } add_action( 'manage_shop_order_posts_custom_column' , 'misha_order_items_column_cnt' ); function misha_order_items_column_cnt( $colname ) { global $the_order; // the global order object if( $colname == 'order_products' ) { // get items from the order global object $order_items = $the_order->get_items(); if ( !is_wp_error( $order_items ) ) { foreach( $order_items as $order_item ) { echo $order_item['quantity'] .' × <a href="' . admin_url('post.php?post=' . $order_item['product_id'] . '&action=edit' ) . '">'. $order_item['name'] .'</a><br />'; // you can also use $order_item->variation_id parameter // by the way, $order_item['name'] will display variation name too } } } } |