• Resolved andreasTypo

    (@andreastypo)


    Hi,

    I’m trying to add some custom columns to the order overview page.
    I have a solution to display anything I want as a new column.
    It just won’t work for a product attribute and I can’t seem to fine how it’s stored in the database to retrieve the value.

    First I create the column

    
    /* CREATE COLUMN SIZE IN ADMIN WOOCOMMERCE ORDERS */
    add_filter( 'manage_edit-shop_order_columns', 'custom_order_cols' );
    function custom_order_cols( $columns ) {
    	$new_columns = ( is_array( $columns ) ) ? $columns : array();
      	unset( $new_columns[ 'order_actions' ] );
    	
      	$new_columns['SIZE'] = 'Size';
    	
      	return $new_columns;
    }
    

    Next, populate the column

    
    /* POPULATE COLUMN SIZE IN ADMIN WOOCOMMERCE ORDERS */
    add_action( 'manage_shop_order_posts_custom_column', 'populate_custom_order_cols', 2 );
    function populate_custom_order_cols( $column ) {
    	global $post;
    	
    	$data = get_post_custom_values( 'pa_maat' );
    
    	if ( $column == 'SIZE' ) {
    	      foreach ( $size_value as $key => $value ) {
                echo "$value"; 
              }
    	}
    }
    

    I can use ‘get_post_custom_values’ to get any value I want from the order. Looking at the database, I can retrieve all values I want, except for the product attribute.
    I just can’t seem to find this value. Tried ‘get_the_terms’ and other…

    Is this even possible?

    Thanks and kind regards!

Viewing 1 replies (of 1 total)
  • jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @andreastypo The product attributes are not stored in the orders themselves. You would need to query wp_woocommerce_order_items for items related to the order in question. From there you can get the product, and then you’d be able to get the attributes for the product.

Viewing 1 replies (of 1 total)
  • The topic ‘Display attributes in order overview’ is closed to new replies.