Commit f30fb1b309a for woocommerce

commit f30fb1b309ad505a2d7e8d55dae5da5a3fc55b8a
Author: Asim Sulehria <de.asimhabib@gmail.com>
Date:   Fri May 1 19:55:59 2026 +0500

    Fix: support customer_note query arg in HPOS OrdersTableQuery (#64467)

    * Fix: support customer_note arg in HPOS OrdersTableQuery

    * Add changefile(s) from automation for the following project(s): woocommerce

    ---------

    Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

diff --git a/plugins/woocommerce/changelog/64467-fix-hpos-customer-note-query b/plugins/woocommerce/changelog/64467-fix-hpos-customer-note-query
new file mode 100644
index 00000000000..76ded12e7e4
--- /dev/null
+++ b/plugins/woocommerce/changelog/64467-fix-hpos-customer-note-query
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix `customer_note` query arg being silently ignored when using HPOS order storage.
\ No newline at end of file
diff --git a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableQuery.php b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableQuery.php
index d242e28751d..30adfe0d70d 100644
--- a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableQuery.php
+++ b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableQuery.php
@@ -203,8 +203,8 @@ class OrdersTableQuery {
 		$this->args       = $args;
 		$this->query_args = $args; // Keep a copy of the original vars used to initialize the query.

-		// TODO: args to be implemented.
-		unset( $this->args['customer_note'], $this->args['name'] );
+		// TODO: 'name' arg (post_name equivalent) is not yet implemented for HPOS.
+		unset( $this->args['name'] );

 		$this->build_query();
 		if ( ! $this->maybe_override_query() ) {
@@ -1267,6 +1267,7 @@ class OrdersTableQuery {
 				'discount_tax_amount',
 				'shipping_total_amount',
 				'shipping_tax_amount',
+				'customer_note',
 			),
 			array( $this, 'arg_isset' )
 		);
diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php
index bbb74c02181..c37e906d9df 100644
--- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php
+++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php
@@ -741,4 +741,53 @@ class OrdersTableQueryTests extends \WC_Unit_Test_Case {
 			$order->delete( true );
 		}
 	}
+
+	/**
+	 * @testdox Querying orders by customer_note returns only matching orders.
+	 */
+	public function test_query_customer_note(): void {
+		$order1 = new \WC_Order();
+		$order1->set_customer_note( 'Please leave at the door' );
+		$order1->save();
+
+		$order2 = new \WC_Order();
+		$order2->set_customer_note( 'Ring the bell twice' );
+		$order2->save();
+
+		$order3 = new \WC_Order();
+		$order3->save();
+
+		// Exact match returns only the matching order.
+		$query = new OrdersTableQuery(
+			array(
+				'customer_note' => 'Please leave at the door',
+				'return'        => 'ids',
+			)
+		);
+		$this->assertEqualsCanonicalizing( array( $order1->get_id() ), $query->orders );
+
+		// Different note returns the other order.
+		$query = new OrdersTableQuery(
+			array(
+				'customer_note' => 'Ring the bell twice',
+				'return'        => 'ids',
+			)
+		);
+		$this->assertEqualsCanonicalizing( array( $order2->get_id() ), $query->orders );
+
+		// Empty string matches orders with no customer note.
+		$query = new OrdersTableQuery(
+			array(
+				'customer_note' => '',
+				'return'        => 'ids',
+			)
+		);
+		$this->assertContains( $order3->get_id(), $query->orders );
+		$this->assertNotContains( $order1->get_id(), $query->orders );
+		$this->assertNotContains( $order2->get_id(), $query->orders );
+
+		$order1->delete( true );
+		$order2->delete( true );
+		$order3->delete( true );
+	}
 }