Commit 7c9a763a221 for woocommerce

commit 7c9a763a221975742fc85c6d78a9dc7cd8b488da
Author: AnnaMag <AnnaMag@users.noreply.github.com>
Date:   Wed Nov 25 15:07:25 2026 +0100

    UCP and agent readiness: four small fixes from the AI regression review (#71362)

    * UCP: send unset attribution fields as (none), as the classic checkout does

    Completing a UCP checkout fired woocommerce_order_save_attribution_data
    with unset fields as '', while the classic checkout sends '(none)'. Core
    stores neither, but an extension checking for '(none)' saw a difference.

    Fixes WOOAIRR-870.

    * Agent readiness: couldn't check the buy action of a product without a price

    WooCommerce prints no offer, so no BuyAction, for a product without a
    price. When an extension made such a product purchasable, the check
    failed it instead of reporting that it couldn't check, as ships() does.

    Fixes WOOAIRR-869.

    * Agent readiness: don't say main image for the image size check

    The check also flags small variation images, but its label, fix and the
    Sales readiness heading said "main image", so a merchant whose main image
    was fine was told to replace it.

    Fixes WOOAIRR-727.

    * Regenerate the Store API filters reference

    Adds woocommerce_product_is_visible from the UCP catalog route and
    woocommerce_cart_ready_to_calc_shipping, and brings two UCP idempotency
    descriptions in line with their docblocks.

    Fixes WOOAIRR-801.

    * Store API hook docs: document $ready and the non-strict idempotency key handling

    The woocommerce_cart_ready_to_calc_shipping stub in OrderController had no
    @param, so the reference showed the filter without its value. The
    woocommerce_ucp_idempotency_strict docblock said a sent key is honored in
    non-strict mode; a malformed key is ignored. Reference regenerated.

diff --git a/plugins/woocommerce/changelog/dev-regenerate-store-api-hook-docs b/plugins/woocommerce/changelog/dev-regenerate-store-api-hook-docs
new file mode 100644
index 00000000000..80071f6e8da
--- /dev/null
+++ b/plugins/woocommerce/changelog/dev-regenerate-store-api-hook-docs
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+Comment: Regenerate the Store API hooks reference after new UCP hook docblocks; docs only.
+
diff --git a/plugins/woocommerce/changelog/fix-agent-readiness-buy-action-no-price b/plugins/woocommerce/changelog/fix-agent-readiness-buy-action-no-price
new file mode 100644
index 00000000000..947f9765204
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-agent-readiness-buy-action-no-price
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+AI shopping health no longer fails the buy action check for a product without a price, which shows no buy link.
diff --git a/plugins/woocommerce/changelog/fix-agent-readiness-image-size-wording b/plugins/woocommerce/changelog/fix-agent-readiness-image-size-wording
new file mode 100644
index 00000000000..2bc6048ed04
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-agent-readiness-image-size-wording
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+AI shopping health no longer says "main image" for the image size check, which also checks variation images.
diff --git a/plugins/woocommerce/changelog/fix-ucp-attribution-none-fields b/plugins/woocommerce/changelog/fix-ucp-attribution-none-fields
new file mode 100644
index 00000000000..24f1eb1f65f
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-ucp-attribution-none-fields
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+AI shopper orders now send unset attribution fields as (none) to extensions, as classic checkout orders do.
diff --git a/plugins/woocommerce/client/blocks/docs/third-party-developers/extensibility/hooks/filters.md b/plugins/woocommerce/client/blocks/docs/third-party-developers/extensibility/hooks/filters.md
index 47385ffdee4..498e6e97283 100644
--- a/plugins/woocommerce/client/blocks/docs/third-party-developers/extensibility/hooks/filters.md
+++ b/plugins/woocommerce/client/blocks/docs/third-party-developers/extensibility/hooks/filters.md
@@ -35,6 +35,7 @@
 - [woocommerce_breadcrumb_product_terms_args](#woocommerce_breadcrumb_product_terms_args)
 - [woocommerce_cart_contents_changed](#woocommerce_cart_contents_changed)
 - [woocommerce_cart_item_permalink](#woocommerce_cart_item_permalink)
+- [woocommerce_cart_ready_to_calc_shipping](#woocommerce_cart_ready_to_calc_shipping)
 - [woocommerce_checkout_link_sold_individually_cart_item_data](#woocommerce_checkout_link_sold_individually_cart_item_data)
 - [woocommerce_checkout_must_be_logged_in_message](#woocommerce_checkout_must_be_logged_in_message)
 - [woocommerce_checkout_show_terms](#woocommerce_checkout_show_terms)
@@ -61,6 +62,7 @@
 - [woocommerce_pay_order_product_in_stock](#woocommerce_pay_order_product_in_stock)
 - [woocommerce_product_details_hooked_blocks](#woocommerce_product_details_hooked_blocks)
 - [woocommerce_product_image_loading_attr](#woocommerce_product_image_loading_attr)
+- [woocommerce_product_is_visible](#woocommerce_product_is_visible)
 - [woocommerce_product_review_comment_form_args](#woocommerce_product_review_comment_form_args)
 - [woocommerce_product_tabs](#woocommerce_product_tabs)
 - [woocommerce_quantity_input_placeholder](#woocommerce_quantity_input_placeholder)
@@ -867,6 +869,27 @@ This is a hook taken from the legacy cart/mini-cart templates that allows the pe

 ---

+## woocommerce_cart_ready_to_calc_shipping
+
+
+This filter is documented in includes/class-wc-cart.php.
+
+```php
+apply_filters( 'woocommerce_cart_ready_to_calc_shipping', bool $ready )
+```
+
+### Parameters
+
+| Argument | Type | Description |
+| -------- | ---- | ----------- |
+| $ready | bool | Whether the cart is ready to calculate shipping. |
+
+### Source
+
+- [StoreApi/Utilities/OrderController.php](../../../../../../src/StoreApi/Utilities/OrderController.php)
+
+---
+
 ## woocommerce_checkout_link_sold_individually_cart_item_data


@@ -1503,6 +1526,28 @@ Allowed values are 'lazy', 'eager', and 'auto'. Any other value will result in d

 ---

+## woocommerce_product_is_visible
+
+
+Filters the product visibility for catalog lookup (same hook as WC_Product::is_visible).
+
+```php
+apply_filters( 'woocommerce_product_is_visible', bool $visible, int $product_id )
+```
+
+### Parameters
+
+| Argument | Type | Description |
+| -------- | ---- | ----------- |
+| $visible | bool | Whether the product is considered visible. |
+| $product_id | int | Product ID. |
+
+### Source
+
+- [StoreApi/Routes/V1/Ucp/AbstractCatalogRoute.php](../../../../../../src/StoreApi/Routes/V1/Ucp/AbstractCatalogRoute.php)
+
+---
+
 ## woocommerce_product_review_comment_form_args


@@ -2121,7 +2166,7 @@ apply_filters( 'woocommerce_ucp_idempotency_retention_seconds', int $seconds )

 ### Description

-How long a retry carrying the same key is answered from storage. The [UCP spec](https://ucp.dev/2026-04-08/specification/checkout-rest/) requires at least 24 hours.
+The UCP spec requires at least 24 hours.

 ### Parameters

@@ -2146,7 +2191,7 @@ apply_filters( 'woocommerce_ucp_idempotency_strict', bool $strict )

 ### Description

-True, the default, matches the UCP OpenAPI document, which declares the header required on every mutating cart operation: a missing or malformed key is refused at 400. False honours a key when one is sent and lets a keyless write through.
+True, the default, matches the UCP specs, and returns 400 for a missing or malformed key. False honors a well-formed key when one is sent, ignores a malformed key, and lets a keyless write through.

 ### Parameters

diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/Checks/ImageTooSmallCheck.php b/plugins/woocommerce/src/Internal/AgentReadiness/Checks/ImageTooSmallCheck.php
index ac93e6c1d56..08181d2cd84 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/Checks/ImageTooSmallCheck.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/Checks/ImageTooSmallCheck.php
@@ -10,7 +10,7 @@ use Automattic\WooCommerce\Internal\AgentReadiness\ProductScan;
 defined( 'ABSPATH' ) || exit;

 /**
- * The main image is under MIN_PIXELS on either side. An image with no recorded
+ * The main image, or a variation's, is under MIN_PIXELS on either side. An image with no recorded
  * size is not flagged. Google requires 500 x 500 from January 31, 2027; before
  * that it is a gap.
  *
@@ -51,21 +51,21 @@ class ImageTooSmallCheck extends AbstractReadinessCheck {
 	 * Merchant-facing label.
 	 */
 	public function label(): string {
-		return __( 'Products whose main image is under 500 x 500 pixels', 'woocommerce' );
+		return __( 'Products with an image under 500 x 500 pixels', 'woocommerce' );
 	}

 	/**
 	 * Why it matters.
 	 */
 	public function why(): string {
-		return __( 'Google\'s spec requires a main image of at least 500 x 500 pixels from January 31, 2027; a smaller one won\'t appear on Google then.', 'woocommerce' );
+		return __( 'Google\'s spec requires an image of at least 500 x 500 pixels from January 31, 2027; a smaller one won\'t appear on Google then.', 'woocommerce' );
 	}

 	/**
 	 * What to do about it.
 	 */
 	public function fix(): string {
-		return __( 'Upload a main image at least 500 x 500 pixels.', 'woocommerce' );
+		return __( 'Upload product and variation images at least 500 x 500 pixels.', 'woocommerce' );
 	}

 	/**
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCopy.php b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCopy.php
index ab1fa13f49d..9f42c5bac63 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCopy.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCopy.php
@@ -249,7 +249,7 @@ final class ReadinessCopy {
 			case 'image_too_small':
 				return self::product(
 					/* translators: %s: names of up to three products, such as "Blue hoodie and Red cap", or number of products. */
-					self::title( $count, $names, _n( 'Use a larger main image on %s', 'Use a larger main image on %s', $count, 'woocommerce' ), __( 'Use a larger main image on a product', 'woocommerce' ), sprintf( _n( 'Use a larger main image on %s product', 'Use a larger main image on %s products', $count, 'woocommerce' ), $n ) ),
+					self::title( $count, $names, _n( 'Use a larger image on %s', 'Use a larger image on %s', $count, 'woocommerce' ), __( 'Use a larger image on a product', 'woocommerce' ), sprintf( _n( 'Use a larger image on %s product', 'Use a larger image on %s products', $count, 'woocommerce' ), $n ) ),
 					__( 'Google asks for images of at least 500 x 500 pixels.', 'woocommerce' )
 				);
 			case 'missing_product_text':
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/StoreOutputChecks.php b/plugins/woocommerce/src/Internal/AgentReadiness/StoreOutputChecks.php
index e45ded0987f..6ff56221c1a 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/StoreOutputChecks.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/StoreOutputChecks.php
@@ -1457,7 +1457,8 @@ class StoreOutputChecks {
 	/**
 	 * Whether a Product item, a variant or one of their offers has a BuyAction potentialAction.
 	 * Null without one when WooCommerce wouldn't print it: it links only a simple product, or a chosen
-	 * variation, that can be bought now (the conditions of WC_Structured_Data::get_product_checkout_url()).
+	 * variation, that can be bought now (the conditions of WC_Structured_Data::get_product_checkout_url()),
+	 * and prints no offer at all for a product without a price.
 	 *
 	 * @param array<int, array<string, mixed>> $products Product items.
 	 * @param \WC_Product|null                 $scanned  The scanned product.
@@ -1473,7 +1474,7 @@ class StoreOutputChecks {
 				}
 			}
 		}
-		if ( null !== $scanned && ( ! $scanned->is_type( ProductType::SIMPLE ) || ( ! $scanned->is_visible() && CatalogVisibility::SEARCH !== $scanned->get_catalog_visibility() ) || ! $scanned->is_publicly_viewable() || ! $scanned->is_purchasable() || ! $scanned->is_in_stock() || ! $scanned->has_enough_stock( 1 ) ) ) {
+		if ( null !== $scanned && ( '' === $scanned->get_price() || ! $scanned->is_type( ProductType::SIMPLE ) || ( ! $scanned->is_visible() && CatalogVisibility::SEARCH !== $scanned->get_catalog_visibility() ) || ! $scanned->is_publicly_viewable() || ! $scanned->is_purchasable() || ! $scanned->is_in_stock() || ! $scanned->has_enough_stock( 1 ) ) ) {
 			return null;
 		}
 		return false;
diff --git a/plugins/woocommerce/src/StoreApi/Routes/V1/Ucp/CheckoutSessionsComplete.php b/plugins/woocommerce/src/StoreApi/Routes/V1/Ucp/CheckoutSessionsComplete.php
index 685be7dc82b..bce25cc3ade 100644
--- a/plugins/woocommerce/src/StoreApi/Routes/V1/Ucp/CheckoutSessionsComplete.php
+++ b/plugins/woocommerce/src/StoreApi/Routes/V1/Ucp/CheckoutSessionsComplete.php
@@ -249,9 +249,9 @@ class CheckoutSessionsComplete extends AbstractCheckoutRoute {
 			return;
 		}

-		// Every field is set, because the listener reads each one without checking it exists.
+		// Every field is set, because the listener reads each one without checking it exists. Unset ones are '(none)', as on the classic checkout.
 		$data = array_merge(
-			array_fill_keys( $attribution->get_field_names(), '' ),
+			array_fill_keys( $attribution->get_field_names(), '(none)' ),
 			array(
 				'source_type' => 'ai_shopper',
 				'utm_source'  => $this->agent_profile_host( (string) $request->get_header( 'UCP-Agent' ) ),
diff --git a/plugins/woocommerce/src/StoreApi/Utilities/OrderController.php b/plugins/woocommerce/src/StoreApi/Utilities/OrderController.php
index 166dee3abcc..178419581af 100644
--- a/plugins/woocommerce/src/StoreApi/Utilities/OrderController.php
+++ b/plugins/woocommerce/src/StoreApi/Utilities/OrderController.php
@@ -1183,6 +1183,8 @@ class OrderController {
 		 * This filter is documented in includes/class-wc-cart.php.
 		 *
 		 * @since 2.7.0
+		 *
+		 * @param bool $ready Whether the cart is ready to calculate shipping.
 		 */
 		if ( (bool) apply_filters( 'woocommerce_cart_ready_to_calc_shipping', true ) ) {
 			// No packages were calculated, so the checkout shows no shipping selector to pick from;
diff --git a/plugins/woocommerce/src/StoreApi/Utilities/Ucp/IdempotencyClaim.php b/plugins/woocommerce/src/StoreApi/Utilities/Ucp/IdempotencyClaim.php
index 14f1bae673b..e3d17158a7d 100644
--- a/plugins/woocommerce/src/StoreApi/Utilities/Ucp/IdempotencyClaim.php
+++ b/plugins/woocommerce/src/StoreApi/Utilities/Ucp/IdempotencyClaim.php
@@ -68,7 +68,7 @@ final class IdempotencyClaim {
 		 * Filters whether a UCP write must carry an `Idempotency-Key`.
 		 *
 		 * True, the default, matches the UCP specs, and returns 400 for a missing or malformed key.
-		 * False honors a key when one is sent and lets a keyless write through.
+		 * False honors a well-formed key when one is sent, ignores a malformed key, and lets a keyless write through.
 		 *
 		 * @since 11.4.0
 		 *
diff --git a/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Routes/UcpCheckout.php b/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Routes/UcpCheckout.php
index 93b68b38505..14d5fe3f081 100644
--- a/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Routes/UcpCheckout.php
+++ b/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Routes/UcpCheckout.php
@@ -1337,6 +1337,31 @@ class UcpCheckout extends ControllerTestCase {
 		$this->assertSame( 'store-api', $order->get_created_via(), 'wc_cancel_unpaid_orders() only cancels checkout and store-api orders.' );
 	}

+	/**
+	 * @testdox Complete sends unset attribution fields as (none), as the classic checkout does, and stores nothing for them.
+	 */
+	public function test_complete_sends_unset_attribution_fields_as_none(): void {
+		$created  = $this->create_ready_checkout();
+		$received = array();
+		$listener = static function ( $order, $data ) use ( &$received ) {
+			unset( $order ); // Avoid parameter not used PHPCS errors.
+			$received = $data;
+		};
+		add_action( 'woocommerce_order_save_attribution_data', $listener, 20, 2 );
+
+		try {
+			$this->request( 'POST', '/checkout-sessions/' . $created['id'] . '/complete' );
+		} finally {
+			remove_action( 'woocommerce_order_save_attribution_data', $listener, 20 );
+		}
+
+		$this->assertArrayHasKey( 'utm_campaign', $received );
+		$this->assertSame( '(none)', $received['utm_campaign'] );
+		$this->assertSame( 'ucp', $received['utm_medium'] );
+		$order = wc_get_order( (int) WC()->session->get( 'store_api_draft_order' ) );
+		$this->assertSame( '', $order->get_meta( '_wc_order_attribution_utm_campaign' ) );
+	}
+
 	/**
 	 * @testdox Complete keeps attribution the order already has.
 	 */
diff --git a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ServedOutputChecksTest.php b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ServedOutputChecksTest.php
index f09dda4bb44..c1d7bbb9930 100644
--- a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ServedOutputChecksTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ServedOutputChecksTest.php
@@ -791,6 +791,15 @@ class ServedOutputChecksTest extends WC_Unit_Test_Case {
 		$this->assertNull( $result( $bare, 'product_buy_action_schema' ), 'Hidden by a visibility filter: WooCommerce prints no BuyAction' );
 		remove_filter( 'woocommerce_product_is_visible', '__return_false' );

+		$price = $this->product->get_regular_price();
+		$this->product->set_regular_price( '' );
+		$this->product->save();
+		add_filter( 'woocommerce_is_purchasable', '__return_true' );
+		$this->assertNull( $result( $bare, 'product_buy_action_schema' ), 'No price, made purchasable by an extension: WooCommerce prints no offer' );
+		remove_filter( 'woocommerce_is_purchasable', '__return_true' );
+		$this->product->set_regular_price( $price );
+		$this->product->save();
+
 		$this->product->set_stock_status( 'outofstock' );
 		$this->product->save();
 		$this->assertNull( $result( $bare, 'product_buy_action_schema' ), 'WooCommerce links only a product in stock to checkout' );