Commit 84025d80873 for woocommerce

commit 84025d8087347e18f1baae01e7fac0f94036e741
Author: Francesco <frosso@users.noreply.github.com>
Date:   Mon Aug 31 19:29:12 2026 +0200

    fix: extensions sub-schema for Store API item (#68158)

diff --git a/plugins/woocommerce/changelog/fix-store-api-item-schema-extensions b/plugins/woocommerce/changelog/fix-store-api-item-schema-extensions
new file mode 100644
index 00000000000..bd6879e1a66
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-store-api-item-schema-extensions
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Store API: the cart items endpoint now publishes and validates extensions registered against `cart-item`, rather than those registered against `product`.
diff --git a/plugins/woocommerce/src/StoreApi/Schemas/V1/ItemSchema.php b/plugins/woocommerce/src/StoreApi/Schemas/V1/ItemSchema.php
index ce954cc1373..97dd79acaa2 100644
--- a/plugins/woocommerce/src/StoreApi/Schemas/V1/ItemSchema.php
+++ b/plugins/woocommerce/src/StoreApi/Schemas/V1/ItemSchema.php
@@ -318,7 +318,9 @@ abstract class ItemSchema extends ProductSchema {
 				'context'     => [ 'view', 'edit' ],
 				'readonly'    => true,
 			],
-			self::EXTENDING_KEY    => $this->get_extended_schema( self::IDENTIFIER ),
+			// static:: so each subclass advertises the extensions registered against its own
+			// endpoint. self:: here would resolve to the inherited ProductSchema identifier.
+			self::EXTENDING_KEY    => $this->get_extended_schema( static::IDENTIFIER ),
 		];
 	}
 }
diff --git a/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Routes/CartItems.php b/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Routes/CartItems.php
index 239d4e89390..9b26bbc7aa5 100644
--- a/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Routes/CartItems.php
+++ b/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Routes/CartItems.php
@@ -8,6 +8,8 @@ namespace Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes;
 use Automattic\WooCommerce\Tests\Blocks\StoreApi\Routes\ControllerTestCase;
 use Automattic\WooCommerce\Tests\Blocks\Helpers\FixtureData;
 use Automattic\WooCommerce\Tests\Blocks\Helpers\ValidateSchema;
+use Automattic\WooCommerce\StoreApi\Schemas\V1\CartItemSchema;
+use Automattic\WooCommerce\StoreApi\Schemas\V1\ProductSchema;
 use WC_Logger;
 use WC_Logger_Interface;
 use Automattic\WooCommerce\Enums\ProductStockStatus;
@@ -410,6 +412,49 @@ class CartItems extends ControllerTestCase {
 		wp_delete_attachment( $image_id, true );
 	}

+	/**
+	 * The cart item schema must advertise cart-item extensions. It inherits the property from
+	 * ItemSchema, which sits below ProductSchema and so can pick up the wrong identifier.
+	 */
+	public function test_get_item_schema_advertises_cart_item_extensions() {
+		$this->mock_extend->register_endpoint_data(
+			array(
+				'endpoint'        => CartItemSchema::IDENTIFIER,
+				'namespace'       => 'cart_item_extension_namespace',
+				'schema_callback' => function () {
+					return array(
+						'cart_item_extension_key' => array(
+							'description' => 'Test key',
+							'type'        => 'boolean',
+						),
+					);
+				},
+			)
+		);
+		$this->mock_extend->register_endpoint_data(
+			array(
+				'endpoint'        => ProductSchema::IDENTIFIER,
+				'namespace'       => 'product_extension_namespace',
+				'schema_callback' => function () {
+					return array(
+						'product_extension_key' => array(
+							'description' => 'Test key',
+							'type'        => 'boolean',
+						),
+					);
+				},
+			)
+		);
+
+		$routes     = new \Automattic\WooCommerce\StoreApi\RoutesController( new \Automattic\WooCommerce\StoreApi\SchemaController( $this->mock_extend ) );
+		$controller = $routes->get( 'cart-items', 'v1' );
+		$schema     = $controller->get_item_schema();
+		$extensions = (array) $schema['properties']['extensions']['properties'];
+
+		$this->assertArrayHasKey( 'cart_item_extension_namespace', $extensions, 'The cart item schema must advertise extensions registered against the cart-item endpoint.' );
+		$this->assertArrayNotHasKey( 'product_extension_namespace', $extensions, 'The cart item schema must not advertise extensions registered against the product endpoint.' );
+	}
+
 	/**
 	 * Test filtering cart item images.
 	 *