woocommerce order product list

The latest version of woocommerce adds a feature to the order list  :  the Purchased column describes items purchased for that order : the number of items is displayed and a click on the line displays all order products.Interesting behaviour when there are many products per order : if you have one or two product per average order, it might be better to display everything in the column, to get a whole view of various recent orders , like a sales report:

woocommerce-order-sales-reportthe code is very simple, use the manage_shop_order_posts_custom_column action to add some text to the purchased column :

 

add_action( 'manage_shop_order_posts_custom_column' , 'po20140324_addColumns_column', 10, 2 );
function po20140324_addColumns_column( $column ) {
 global $post, $woocommerce, $the_order;

    switch ( $column ) {

        case 'order_items' :
            $terms = $the_order->get_items();

	      if ( is_array( $terms ) ) {
             	foreach($terms as $term)
		{
		echo '<br />' . $term['item_meta']['_qty'][0] .' x ' . $term['name'] .'';
		}
              } else {
              	_e( 'No product to display ? ', 'woocommerce' );
		}
            break;

    }
}

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *