1

After updating to Woocommerce 3.0, in the Woocommerce ORDER page (where you can check all the orders made by customers, with order status, billing address, shipping address, total, etc.) is missing the column with the items purchased by the customer. Before WC update, that column was there. Now it is gone.

Could anyone help me to add again this column?

Thanks a lot!

1

I have already manage to create a column thanks to this:

    // ADDING COLUMN TITLES
add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column',11);
function custom_shop_order_column($columns)
{
   //add columns
    $columns['my-column1'] = __( 'Column Title','theme_slug');
   return $columns;
}

// adding the data for each orders by column (example)
add_action( 'manage_shop_order_posts_custom_column' , 'custom_orders_list_column_content', 10, 2 );
function custom_orders_list_column_content( $column )
{
    global $post, $woocommerce, $the_order;
    $order_id = $the_order->id;

    switch ( $column )
    {
        case 'my-column1' :
            $myVarOne = wc_get_order_item_meta( $order_id, '_the_meta_key1', true );
            echo $myVarOne;
            break;
    }

But I don't know how to add the data to this columns. I need to add the items purchased by the customers. Is it possible?

Thanks!

1

Here is a free plugin that restores it to just like it was before:

https://wordpress.org/plugins/restore-purchased-items-column/

1

I use this to add an Ordered Products column right after the Date column (fits nicely there). Each product is also linked to it's proper edit page.

// ----- add column to orders that shows which products were ordered -----
function ec_order_items_column($columns) {
    $new_columns = array();
    foreach($columns as $key=>$column){
        $new_columns[$key] = $columns[$key];
        if($key === 'order_date') {
            $new_columns['ordered_products'] = __('Ordered Products','woo-custom-ec');
        }
    }
    return $new_columns;

    //$columns['order_products'] = "Purchased Items";
    //return $columns;
}
add_filter('manage_edit-shop_order_columns', 'ec_order_items_column', 99 );

// ----- add data to new column that shows which products were ordered -----
function ec_order_items_column_cnt($column) {
    global $the_order; // the global order object
    if($column == 'ordered_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'].'&nbsp;&times;&nbsp;<a href="'.admin_url('post.php?post='.$order_item['product_id'].'&action=edit' ).'">'.$order_item['name'].'</a><br />';
            }
        }
    }
}
add_action('manage_shop_order_posts_custom_column', 'ec_order_items_column_cnt', 99);

enter image description here

0

If you want to display the purchased products in a column, you can use this code:

add_action( 'manage_shop_order_posts_custom_column' , 'custom_orders_list_column_content', 10, 2 );
function custom_orders_list_column_content( $column )
{
    global $the_order;
    $order_id = $the_order->id;

    switch ( $column )
    {
        case 'my-column1' :
            $order_items = $the_order->get_items();
            foreach( $order_items as $myVarOne ) {
                echo $myVarOne['quantity'] .'&nbsp;&times;&nbsp;'. $myVarOne['name'] .'<br />';
            }
            break;
    }
}

You can also view the complete code with screenshots in this tutorial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.