Customising order notes based on product categories can help streamline fulfilment processes or communicate specific details about orders to your team. For example, you can automatically add a note if the order contains products from a certain category, such as “fragile items” or “perishable goods.”
In this guide, we’ll show you how to dynamically create custom order notes in WooCommerce based on product categories, without using a plugin.
Step 1: Identify Product Categories in the Order
To create custom order notes, you first need to check whether the order contains products from specific categories. WooCommerce makes it easy to retrieve product information from orders.
Code to Check Product Categories in an Order
Add the following function to your theme’s functions.php file or your child theme:
/*
* Snippet: How to Create Custom Order Notes Based on Product Categories in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1759
* Tested with WooCommerce 10.7.0
* "This function checks if an order contains products from specific categories"
*/
function wcsuccess_order_contains_category( $order, $category_slug ) {
foreach ( $order->get_items() as $item_id => $item ) {
$product_id = $item->get_product_id();
if ( has_term( $category_slug, 'product_cat', $product_id ) ) {
return true; // Order contains at least one product from the category
}
}
return false;
}
Explanation:
- Order Items: Loops through the items in the order.
- Category Check: Uses
has_term()to check if a product belongs to the specified category. - Reusability: The function is designed to work with any category slug.
Step 2: Add Custom Order Notes Based on Categories
Now that you can detect categories in an order, use this functionality to add custom order notes when certain conditions are met.
Code to Add Custom Order Notes
Add this code to your functions.php file:
/*
* Snippet: How to Create Custom Order Notes Based on Product Categories in WooCommerce – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1759
* Tested with WooCommerce 10.7.0
* "This function adds custom order notes based on product categories"
*/
function wcsuccess_add_custom_order_notes( $order_id ) {
$order = wc_get_order( $order_id );
// Define custom messages for specific categories
$category_notes = array(
'fragile-items' => __( 'Handle with care: This order contains fragile items.', 'woocommerce' ),
'perishable-goods' => __( 'This order contains perishable goods. Prioritise shipping.', 'woocommerce' ),
);
foreach ( $category_notes as $category_slug => $note ) {
if ( wcsuccess_order_contains_category( $order, $category_slug ) ) {
// Add the custom note
$order->add_order_note( $note );
}
}
}
add_action( 'woocommerce_checkout_order_processed', 'wcsuccess_add_custom_order_notes', 10, 1 );
Explanation:
- Order Notes: Dynamically adds notes to the order if it contains products from specific categories.
- Category-Specific Notes: Maps each category slug to a custom note.
- Hook: Runs when the order is processed, ensuring the notes are added during checkout.
Step 3: Optional – Add Notes Only for Admins
If you want these notes to be visible only to admins (and not customers), you can set the notes as private.
Update the Code for Admin-Only Notes
Modify the add_order_note line:
$order->add_order_note( $note, false ); // Second parameter 'false' makes the note private
Explanation:
- Private Notes: Setting the second parameter to
falseensures the note is visible only to store admins in the WooCommerce admin panel.
Step 4: Test the Custom Order Notes
Example Workflow:
- Create an Order:
- Add products from categories like “fragile-items” or “perishable-goods” to the cart.
- Checkout:
- Place the order and check the admin panel for the generated order notes.
- Confirm Notes:
- Verify that the correct notes are added based on the categories of products in the order.
Example Use Case
- Category Setup: Add “fragile-items” and “perishable-goods” as categories to your products.
- Custom Notes:
- For “fragile-items”: “Handle with care: This order contains fragile items.”
- For “perishable-goods”: “This order contains perishable goods. Prioritise shipping.”
- Order Management: These notes help your team manage and fulfil orders more effectively.
Conclusion
Adding custom order notes based on product categories in WooCommerce can simplify your fulfilment process and improve communication within your team. By following this guide, you can dynamically generate order notes tailored to the products in each order.
Test these changes in a staging environment before applying them to your live site. For more WooCommerce customisation options, explore our WooCommerce Visual Hooks Guide or use our wp-config generator for advanced configurations.
I have been working with WordPress and WooCommerce since 2012 and have developed a deep knowledge of the content management system. Since 2012, I have developed several plugins and designed dozens of websites utilising different frameworks, CMS’s and programming languages. I am proficient in PHP, Python, Java, C, C++, R and JavaScript with limited experience in Go, Kotlin and Swift.
Educationally, I have a Master’s degree in cyber security a Bachelor’s (Hons, First Class) in Applied Research and a Graduate Certificate in Data Science. I’m currently undertaking PhD studies investigating IoT cybersecurity. I recently graduated with First Class Honours and Masters of Information Technology, receiving the Executive Dean’s Award for studies undertaken in the 2021 and 2022 academic years. I have worked in the information technology industry for the past 11 years primarily as a software/web developer specific to design, optimisation, network management and security. My research interests are in the areas of Internet of Things (IoT), 5G and Beyond Networks, information security for wireless networks and software development.
Stay In Touch

