Add Customer Notes Column to WooCommerce Orders Table

Beginner
✓ Tested
📅 August 24, 2025
⬇️ 0 Downloads
📋 6 Copies

This snippet adds a “Customer Note” column to your WooCommerce orders admin table, displaying any special instructions or comments customers left during checkout. Never miss important delivery instructions or special requests again!

What does this code do?

Adds a dedicated column in the orders list showing customer notes/comments with smart truncation for long messages. Includes an expand/collapse feature for lengthy notes and visual indicators for orders requiring special attention.

Features:

  • Smart Display: Shows first 15 words with [more] link for longer notes
  • Visual Indicators: Comment icon and colored background for easy spotting
  • Expandable Notes: Click to expand/collapse long customer messages
  • Sortable Column: Sort orders by presence of customer notes
  • Clean Interface: Shows “–” for orders without notes
  • Priority Highlighting: Long notes get special border indicator

Perfect for:

  • Identifying orders with special delivery instructions
  • Spotting gift messages quickly
  • Finding orders that need special handling
  • Improving customer service response time
  • Preventing missed customer requests

Visual features:

  • Yellow background for notes visibility
  • Comment icon for quick identification
  • Orange border for lengthy/important notes
  • Smooth expand/collapse animation

⚠️ Important Warnings

⚠️ Only works with WooCommerce 8.0+ (HPOS compatible)
⚠️ Long customer notes might affect table layout on small screens
⚠️ Some special characters in notes might need escaping
⚠️ Column width may need adjustment based on typical note length
⚠️ JavaScript required for expand/collapse functionality
⚠️ Sorting works alphabetically, not by note length
⚠️ Filter dropdown only works with legacy orders storage
⚠️ Very long notes (1000+ characters) might slow page load slightly
💻 PHP Code
/**
 * Add customer notes column to WooCommerce orders admin table
 * Shows order notes/comments left by customers during checkout
 * Prefix: tpsc_ (TP Snippet Collection)
 */

// Add customer note column to orders table
add_filter('manage_woocommerce_page_wc-orders_columns', 'tpsc_add_customer_note_column');
function tpsc_add_customer_note_column($columns) {
    $new_columns = array();
    
    foreach ($columns as $column_name => $column_info) {
        $new_columns[$column_name] = $column_info;
        
        // Add after order status column
        if ('order_status' === $column_name) {
            $new_columns['customer_note'] = __('Customer Note', 'woocommerce');
        }
    }
    
    return $new_columns;
}

// Add content to customer note column
add_action('manage_woocommerce_page_wc-orders_custom_column', 'tpsc_show_customer_note_content', 10, 2);
function tpsc_show_customer_note_content($column, $order) {
    if ('customer_note' === $column) {
        if (!is_a($order, 'WC_Order')) {
            $order = wc_get_order($order);
        }
        
        if (!$order) {
            return;
        }
        
        $note = $order->get_customer_note();
        
        if ($note) {
            // Truncate long notes
            $truncated = wp_trim_words($note, 15, '...');
            $has_more = (strlen($note) > strlen($truncated));
            
            // Output note with icon
            echo '<div class="tpsc-customer-note">';
            echo '<span class="dashicons dashicons-admin-comments"></span>';
            echo '<span class="tpsc-note-text" data-full-note="' . esc_attr($note) . '">';
            echo esc_html($truncated);
            
            if ($has_more) {
                echo ' <a href="#" class="tpsc-note-toggle" onclick="tpscToggleNote(this); return false;">[more]</a>';
            }
            
            echo '</span>';
            echo '</div>';
        } else {
            echo '<span class="na">–</span>';
        }
    }
}

// Add styles and scripts for customer note column
add_action('admin_head', 'tpsc_customer_note_column_assets');
function tpsc_customer_note_column_assets() {
    $screen = get_current_screen();
    
    if ($screen && 'woocommerce_page_wc-orders' === $screen->id) {
        ?>
        <style>
            /* Column styling */
            .column-customer_note {
                width: 15%;
                min-width: 150px;
            }
            
            /* Note container */
            .tpsc-customer-note {
                display: flex;
                align-items: flex-start;
                gap: 6px;
                padding: 5px;
                background: #fff9e6;
                border: 1px solid #f0e5c1;
                border-radius: 4px;
                font-size: 13px;
                line-height: 1.5;
            }
            
            /* Icon styling */
            .tpsc-customer-note .dashicons {
                flex-shrink: 0;
                color: #f0ad4e;
                font-size: 16px;
                margin-top: 2px;
            }
            
            /* Note text */
            .tpsc-note-text {
                flex: 1;
                color: #666;
            }
            
            /* Toggle link */
            .tpsc-note-toggle {
                color: #2271b1;
                text-decoration: none;
                font-weight: 600;
                font-size: 11px;
                white-space: nowrap;
            }
            
            .tpsc-note-toggle:hover {
                text-decoration: underline;
            }
            
            /* Expanded note */
            .tpsc-note-expanded {
                background: #fffbf0;
                border-color: #e8d89f;
            }
            
            .tpsc-note-expanded .tpsc-note-text {
                white-space: pre-wrap;
                word-break: break-word;
            }
            
            /* Empty state */
            .column-customer_note .na {
                color: #999;
                font-style: italic;
            }
            
            /* Hover effect */
            .tpsc-customer-note:hover {
                background: #fffcf2;
                border-color: #e8d89f;
                box-shadow: 0 1px 3px rgba(0,0,0,0.1);
            }
            
            /* Priority indicator for long notes */
            .tpsc-customer-note.has-long-note {
                border-left: 3px solid #f0ad4e;
            }
        </style>
        
        <script>
        function tpscToggleNote(link) {
            const noteSpan = link.parentElement;
            const container = noteSpan.closest('.tpsc-customer-note');
            const fullNote = noteSpan.getAttribute('data-full-note');
            
            if (link.textContent === '[more]') {
                // Show full note
                noteSpan.innerHTML = noteSpan.getAttribute('data-full-note') + 
                    ' <a href="#" class="tpsc-note-toggle" onclick="tpscToggleNote(this); return false;">[less]</a>';
                container.classList.add('tpsc-note-expanded');
            } else {
                // Show truncated note
                const truncated = fullNote.split(' ').slice(0, 15).join(' ');
                noteSpan.innerHTML = truncated + '...' +
                    ' <a href="#" class="tpsc-note-toggle" onclick="tpscToggleNote(this); return false;">[more]</a>';
                container.classList.remove('tpsc-note-expanded');
            }
        }
        
        // Add long note indicator on load
        document.addEventListener('DOMContentLoaded', function() {
            document.querySelectorAll('.tpsc-customer-note').forEach(function(note) {
                const fullNote = note.querySelector('.tpsc-note-text').getAttribute('data-full-note');
                if (fullNote && fullNote.length > 100) {
                    note.classList.add('has-long-note');
                }
            });
        });
        </script>
        <?php
    }
}

📝 Installation Instructions

INSTALLATION:
1. Copy the entire code
2. Go to WordPress Admin → Appearance → Theme Editor → functions.php
3. Paste at the bottom of the file
4. Save changes
5. Navigate to WooCommerce → Orders to see the new column

COLUMN APPEARS:
- After the "Status" column by default
- Shows customer checkout notes/comments
- Works with HPOS and legacy order storage

TO CHANGE COLUMN POSITION:
Find line: if ('order_status' === $column_name)
Replace 'order_status' with:
- 'order_date' - to show after date
- 'order_total' - to show after total
- 'shipping_address' - to show after shipping

CUSTOMIZATION OPTIONS:

Word limit for truncation (default 15):
- Find: wp_trim_words($note, 15
- Change 15 to your preferred number

Column width:
- Find: width: 15%;
- Adjust percentage as needed

Note background color:
- Find: background: #fff9e6;
- Change to your preferred color

Icon color:
- Find: color: #f0ad4e;
- Change to match your admin theme

USAGE TIPS:
- Click [more] to expand long notes
- Click [less] to collapse back
- Look for orange border = important/long notes
- Sort by customer note column to group orders with notes
- Hover over notes for slight highlight effect

TESTING:
1. Create test order with customer note at checkout
2. Check WooCommerce → Orders
3. Verify note appears in new column
4. Test expand/collapse for long notes
5. Try sorting by the column

📸 Screenshots

💬 Let's Connect and Share!

Got a question about this snippet?

Something not working as expected? Need help customizing it for your specific needs?

💡

Want to request a custom snippet?

Have an idea for functionality you're missing on your site? Tell us what you're looking for!

🤝

Have an awesome snippet you're using?

Share it with us! Our community loves learning and growing together.

No comments yet.

Leave a Comment

Leave a Comment

To leave a comment, please enter your email address. We will send you a verification code to confirm your identity.

Email Verification

We sent a 6-digit verification code to your email address. Please check your inbox and enter the code below:

Write Your Comment

Great! Your email is verified. Now you can write your comment:

Comment Submitted!