Articles

WooCommerce Hackery – Adding Custom Company Fields to Orders Page

26
0

Dear Diary.. Don’t forget this – “Adding company to the orders screen” and “adding a custom order status”.
Click screen options and add quick click “actions” and “Company”


// 1. Add custom column header to the orders list
add_filter( 'manage_woocommerce_page_wc-orders_columns', 'add_company_order_column' );
function add_company_order_column( $columns ) {
    $new_columns = array();
    foreach ( $columns as $key => $column ) {
        $new_columns[$key] = $column;
        // Insert the Company column after the Order number/status
        if ( 'order_status' === $key ) {
            $new_columns['billing_company'] = 'Company';
        }
    }
    $new_columns['billing_company'] = 'Company';
    return $new_columns;
}

// 2. Populate the custom column with company data
add_action( 'manage_woocommerce_page_wc-orders_custom_column', 'fill_company_order_column', 10, 2 );
function fill_company_order_column( $column, $order ) {
    if ( 'billing_company' === $column ) {
        $company = $order->get_billing_company();
        echo ! empty( $company ) ? esc_html( $company ) : '—';
    }
}

Plugin 2: Custom Order Status Manager for WooCommerce

Setting up WooCommerce Actions and A Custom Status

Plugin 3: Product Customer List for WooCommerce – Possibly the most essential WooCommerce Plugin ever. Easy export for any orders of a specific product including custom fields and statuses.

WooCommerce Customer Product Export Easy Free