Commit 3d7f307e3de for woocommerce

commit 3d7f307e3de7434a4bcfffd63d485b963c021b30
Author: Luis Felipe Zaguini <26530524+zaguiini@users.noreply.github.com>
Date:   Fri Oct 16 18:17:15 2026 -0300

    Pass order statuses without the wc- prefix to the order query filter (#69954)

    * Pass order statuses without the wc- prefix to the order query filter

    The orders-query ability added the wc- prefix to every status, order
    statuses included. Callbacks on woocommerce_order_query_args got
    wc-processing where 11.2.1 passed processing. The ability now adds the
    prefix only to statuses outside wc_get_order_statuses(), because the
    order query adds it to order statuses itself.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    * Capture the first order query in the orders-query test helper

    With HPOS off, a found order triggers a later order query. The helper
    kept that query and not the one the ability runs.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    * Use wc_is_order_status() to skip the prefix for order statuses

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

    ---------

    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/plugins/woocommerce/changelog/fix-orders-query-status-prefix b/plugins/woocommerce/changelog/fix-orders-query-status-prefix
new file mode 100644
index 00000000000..4f417fa1614
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-orders-query-status-prefix
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Pass order statuses to the woocommerce_order_query_args filter without the wc- prefix again when the orders-query ability runs.
diff --git a/plugins/woocommerce/src/Internal/Abilities/Domain/OrdersQuery.php b/plugins/woocommerce/src/Internal/Abilities/Domain/OrdersQuery.php
index dd67e105ca9..1a17c1ed1dd 100644
--- a/plugins/woocommerce/src/Internal/Abilities/Domain/OrdersQuery.php
+++ b/plugins/woocommerce/src/Internal/Abilities/Domain/OrdersQuery.php
@@ -378,15 +378,17 @@ class OrdersQuery extends AbstractDomainAbility implements AbilityDefinition {
 	}

 	/**
-	 * Add the `wc-` prefix to a status that is registered with it. The order
-	 * query adds the prefix only to order statuses, not to the statuses of
-	 * other order types.
+	 * Add the `wc-` prefix to a status of another order type that is registered
+	 * with it. The order query adds the prefix to order statuses itself, so those
+	 * stay without it, as `woocommerce_order_query_args` callbacks expect.
 	 *
 	 * @param string $status Status slug without the `wc-` prefix.
 	 * @return string
 	 */
 	private static function prepare_status_arg( string $status ): string {
-		return in_array( 'wc-' . $status, get_post_stati(), true ) ? 'wc-' . $status : $status;
+		$prefixed = 'wc-' . $status;
+
+		return ! wc_is_order_status( $prefixed ) && in_array( $prefixed, get_post_stati(), true ) ? $prefixed : $status;
 	}

 	/**
diff --git a/plugins/woocommerce/tests/php/src/Internal/Abilities/AbilitiesLoaderTest.php b/plugins/woocommerce/tests/php/src/Internal/Abilities/AbilitiesLoaderTest.php
index b701f2450e0..7e769993e98 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Abilities/AbilitiesLoaderTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Abilities/AbilitiesLoaderTest.php
@@ -473,13 +473,13 @@ class AbilitiesLoaderTest extends \WC_Unit_Test_Case {
 	}

 	/**
-	 * @testdox Should use the same default statuses as before for shop_order.
+	 * @testdox Should pass the default order statuses without the wc- prefix, as before, for shop_order.
 	 */
 	public function test_orders_query_default_statuses_match_trunk_for_shop_order(): void {
 		$expected = array();
 		foreach ( array_keys( wc_get_order_statuses() ) as $status ) {
 			if ( 'wc-checkout-draft' !== $status ) {
-				$expected[] = $status;
+				$expected[] = OrderUtil::remove_status_prefix( $status );
 			}
 		}

@@ -541,7 +541,7 @@ class AbilitiesLoaderTest extends \WC_Unit_Test_Case {
 	public function test_orders_query_accepts_a_list_of_statuses(): void {
 		$query_args = $this->capture_order_query_args( array( 'status' => array( 'on-hold', 'processing' ) ) );

-		$this->assertSame( array( 'wc-on-hold', 'wc-processing' ), $query_args['status'] ?? null );
+		$this->assertSame( array( 'on-hold', 'processing' ), $query_args['status'] ?? null );

 		$result = wp_get_ability( 'woocommerce/orders-query' )->execute( array( 'status' => array( 'processing', 'not-a-status' ) ) );

@@ -631,9 +631,9 @@ class AbilitiesLoaderTest extends \WC_Unit_Test_Case {
 	 * @return array
 	 */
 	private function capture_order_query_args( array $input ): array {
-		$captured = array();
+		$captured = null;
 		$capture  = static function ( $args ) use ( &$captured ) {
-			$captured = $args;
+			$captured ??= $args;
 			return $args;
 		};

@@ -646,7 +646,7 @@ class AbilitiesLoaderTest extends \WC_Unit_Test_Case {

 		$this->assertNotWPError( $result );

-		return $captured;
+		return $captured ?? array();
 	}

 	/**