• In the Woocommerce orders overview I want to add a column which shows the product name(s).

    First I added an extra column to the custom post ‘shop_order’.

    add_filter('manage_edit-shop_order_columns', 'extra_column');
    	function extra_column($columns) {
    		$columns['title'] = 'Product';
    		return $columns;
    	}

    Working fine…but it needs to show the title from the custom post ‘product’.

    Anyone?

    https://www.ads-software.com/extend/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • You probably need another filter. Possibly like this:

    add_action( 'manage_shop_order_posts_custom_column', 'my_custom_order_columns', 2 );
    
    function my_custom_order_columns( $column ) {
    	switch ( $column ) {
    		case "title" :
    // code to look up product title goes here
    // echo get_the_title( $PRODUCT_ID_GOES_HERE );
    
    		break;
    }

    yspo0, did you get this to work?

    Thread Starter Yasp0

    (@yasp0)

    Yes, a friend of mine wrote a plugin. This should do it:

    add_filter( 'manage_edit-shop_order_columns', 'imarcon_set_custom_column_order_columns');
    
    function imarcon_set_custom_column_order_columns($columns) {
    // global $woocommerce;
    $nieuwearray = array();
     foreach($columns as $key => $title) {
       if ($key=='billing_address') // in front of the Billing column
         $nieuwearray['order_producten']  = __( 'Products', 'woocommerce' );
        $nieuwearray[$key] = $title;
      }
        return $nieuwearray ;
    }
    
    add_action( 'manage_shop_order_posts_custom_column' , 'imarcon_custom_shop_order_column', 10, 2 );
    function imarcon_custom_shop_order_column( $column ) {
     global $post, $woocommerce, $the_order;
    
        switch ( $column ) {
    
            case 'order_producten' :
                $terms = $the_order->get_items();
    
    	      if ( is_array( $terms ) ) {
                 	foreach($terms as $term)
    		{
    		echo $term['item_meta']['_qty'][0] .' x ' . $term['name'] .'<br />';
    		}
                  } else {
                  	_e( 'Unable get the producten', 'woocommerce' );
    		}
                break;
    
        }
    }

    It returns e.g. : 2 x productname

    thanks, and thank you for the quick response!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add product as column in orders overview’ is closed to new replies.