Find WooCommerce Order Notes

User
find manually added notes from order detail page woocommerce wp admin
Assistant
In WooCommerce, manually added order notes can be found in the **Order Notes** section on the order details page in the WordPress admin panel. Here's how you can locate them:

### Steps to Find Manually Added Order Notes:
1. **Go to WooCommerce Admin**
– Log in to your WordPress admin panel.
– Navigate to **WooCommerce** > **Orders**.

2. **Open an Order**
– Click on the order you want to check.

3. **Locate the Order Notes Section**
– Scroll down to the **Order Notes** panel on the right side of the order details page.

4. **Identify Manually Added Notes**
– WooCommerce differentiates notes by color:
– **Manually added notes** (by admin) are in white or light gray.
– **Automated system notes** (by WooCommerce) are in a darker gray.
– **Customer notes** (sent to the customer) are in purple.

5. **Filter or Add a New Note** (Optional)
– You can manually add a new note by entering text in the "Add note" field and selecting whether it should be a **private note** or a **customer note**.

Would you like to programmatically retrieve these notes or display them differently in your WooCommerce admin?

User
find by db query
Assistant
To find manually added order notes in WooCommerce via a **database query**, you need to look into the **`wp_comments`** table where WooCommerce stores order notes.

### **SQL Query to Find Manually Added Order Notes**

SELECT comment_ID, comment_post_ID, comment_author, comment_date, comment_content 
FROM wp_comments 
WHERE comment_type = 'order_note' 
AND comment_author != 'WooCommerce' 
ORDER BY comment_date DESC;

### **Explanation:**
– `comment_type = 'order_note'` โ†’ Filters order notes.
– `comment_author != 'WooCommerce'` โ†’ Excludes system-generated notes.
– `ORDER BY comment_date DESC` โ†’ Shows the most recent notes first.

### **If You Want Notes for a Specific Order ID**
Replace `ORDER_ID` with the actual order ID:

SELECT comment_ID, comment_post_ID, comment_author, comment_date, comment_content 
FROM wp_comments 
WHERE comment_type = 'order_note' 
AND comment_author != 'WooCommerce' 
AND comment_post_ID = ORDER_ID 
ORDER BY comment_date DESC;

### **If Your Table Prefix is Different**
Replace `wp_` with your actual table prefix (e.g., `wp123_`).

Do you need help running this query or integrating it into your WooCommerce admin? ๐Ÿš€

User
but it also inlcudes system generated notes like order status change
I want manually added notes
Assistant
To retrieve **only manually added order notes** from the WooCommerce database and exclude system-generated ones (like order status changes), use the following query:

### **Optimized SQL Query:**

SELECT comment_ID, comment_post_ID, comment_author, comment_date, comment_content 
FROM wp_comments 
WHERE comment_type = 'order_note' 
AND comment_author NOT IN ('WooCommerce', 'WordPress') 
ORDER BY comment_date DESC;

### **Why This Works:**
– **`comment_type = 'order_note'`** โ†’ Ensures we are fetching only order notes.
– **`comment_author NOT IN ('WooCommerce', 'WordPress')`** โ†’ Excludes system-generated notes (e.g., status changes).
– **Manually added notes** are typically created by an admin user and will have the `comment_author` field set to the actual admin username.

### **Find Manually Added Notes for a Specific Order:**

SELECT comment_ID, comment_post_ID, comment_author, comment_date, comment_content 
FROM wp_comments 
WHERE comment_type = 'order_note' 
AND comment_author NOT IN ('WooCommerce', 'WordPress') 
AND comment_post_ID = ORDER_ID 
ORDER BY comment_date DESC;

Replace `ORDER_ID` with the actual order ID.

### **Alternative Approach: Checking Manually Added Notes**
Since WooCommerce does not explicitly mark notes as "manual," another way is to exclude notes that contain common system-generated phrases like:

SELECT comment_ID, comment_post_ID, comment_author, comment_date, comment_content 
FROM wp_comments 
WHERE comment_type = 'order_note' 
AND comment_author NOT IN ('WooCommerce', 'WordPress') 
AND comment_content NOT LIKE '%status changed%' 
AND comment_content NOT LIKE '%Order refunded%' 
AND comment_content NOT LIKE '%Stock level reduced%'
ORDER BY comment_date DESC;

This filters out notes related to status changes, refunds, and stock adjustments.

Let me know if you need further refinements! ๐Ÿš€

Leave a Comment

Your email address will not be published. Required fields are marked *