Commit e5fe3eedc47 for woocommerce
commit e5fe3eedc47ff04001f79cc973b6e5b02e49a61e
Author: AnnaMag <AnnaMag@users.noreply.github.com>
Date: Mon Nov 23 12:03:08 2026 +0100
Agent readiness: first visit, running check and AI shopping switch as in the design (#71287)
* Agent readiness: match the first visit and running check to the design
The page's background reaches the bottom of the screen. Before the first
check the card shows Not checked yet and Check your store; while a check
runs it shows a spinner, Checking your store and a turned-off Check again.
Draft policy pages in Fix first offer Edit page, as the Setup checklist
does, with the policy named for screen readers, so the button column no
longer squeezes the titles.
* Agent readiness: confirm the AI shopping switch in a snackbar
As in the design, turning AI shopping on or off shows "AI assistants can
now shop your store." or "AI assistants can no longer shop your store."
in the settings page's snackbar, instead of a line under the switch that
stayed while AI shopping was on. The page reloads after the switch saves,
so the next page shows it; with unsaved fields it shows at once.
* Agent readiness: centre the AI shopping switch's snackbar, as in the design
* Agent readiness: link Learn how it works on the AI shopping switch to the AI shopping doc
* Agent readiness: review fixes and prototype gaps on AI shopping
- Link the product name in a page check's found line where the name starts, so a name that is also an earlier word, or sits elsewhere in a translation, links the right text.
- The AI shopping badge counts the same Required steps as the card's Continue setup button, so it no longer says Active next to Continue setup.
- One failing product opens its edit page instead of a Products list filtered to one item.
- The catalog search check no longer shows the HTTP status to merchants; the report still keeps it.
- The Setup checklist shows a green All steps done badge once no step is left, as in the prototype.
* Agent readiness: policy buttons keep their visible name, and only the health page fills the screen
The policy buttons' accessible name is their visible text (Edit page), with the policy read as the
description, so voice control finds them (WCAG 2.5.3). The full-height background no longer applies to
the AI tools Overview and AI shopping panels inside the settings form.
* Agent readiness: link Fix first to Analytics settings while past orders aren't imported
The ranking line named Analytics > Settings as plain text. Fix first's link slot, already used to turn
Analytics on, now opens Analytics settings, where the import is, as other fix lines link where to fix.
* Keep the AI shopping design changelog out of the release notes
* Agent readiness: WordPress UI buttons are semibold, and Check again uses the design's outline button
The status card's button was the components Button restyled to look like
the prototype. It is now the WordPress UI outline button the prototype uses,
and stays focusable while a check runs. The WordPress UI version bundled
here sets buttons to medium (499); the design is semibold (600), so every
WordPress UI button on the AI shopping pages gets 600.
* Agent readiness: Couldn't check on cards where a check couldn't run, and a coming soon notice over live results
Following the design's badge review: a question card where nothing failed but
a check couldn't run says Couldn't check, instead of No issues, Not checked yet,
No products or Not checked; the row says why. Failing catalog search has no
badge, like any failing check that isn't Required, instead of Warning.
In coming soon mode, results from a check that ran while the store was live get
the AI shopping coming soon notice under Last checked, saying they are from
when the store was live. A check in coming soon mode replaces them, and the
cards say why the checks didn't run.
* Agent readiness: setup steps go by importance, open or done
Steps that block AI shopping (live, HTTPS, readable permalinks) come
first, then payments, the privacy, terms and refund pages, search engine
indexing and order emails, then guest checkout and the shipping policy.
Completed steps now use the same order as open ones; before, they kept
the order the conditions are defined in.
* Agent readiness: match done-step order and UTF-16 name links
Completed steps skipped the Required-first pass, so a Required step could sit after an Optional one. Product-name links now count UTF-16 code units, the index the page uses to slice the text.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Agent readiness: clean the checked flag, schema, and product lookups
The first visit was a translated sentence nothing rendered. It is now a boolean. The coming soon notice is in the view schema, a product check is loaded once per view, and the link helper no longer comes from the checklist.
diff --git a/plugins/woocommerce/changelog/update-sales-readiness-first-visit b/plugins/woocommerce/changelog/update-sales-readiness-first-visit
new file mode 100644
index 00000000000..dfd42ea17e9
--- /dev/null
+++ b/plugins/woocommerce/changelog/update-sales-readiness-first-visit
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Match AI shopping first visit, running check and switch snackbar to the design; behind a hidden flag.
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/ai-shopping.scss b/plugins/woocommerce/client/admin/client/sales-readiness/ai-shopping.scss
index 89b8a1e8dd0..7fb6e7b0022 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/ai-shopping.scss
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/ai-shopping.scss
@@ -166,12 +166,6 @@ body.woocommerce_page_wc-settings:has(.wc-ai-shopping) {
}
}
-// The coming soon notice's button is a link, so wp-admin's link blue would override the neutral button's label.
-.wc-ai-shopping__notice-action,
-.wc-ai-shopping__notice-action:is(:hover, :focus, :active) {
- color: var(--wpds-color-foreground-interactive-neutral);
-}
-
// DataForm cards.
.wc-ai-shopping .dataforms-layouts-card__field {
position: relative;
@@ -207,3 +201,9 @@ body.woocommerce_page_wc-settings:has(.wc-ai-shopping) {
inset-block-start: var(--wpds-dimension-padding-2xl);
inset-inline-end: var(--wpds-dimension-padding-2xl);
}
+
+// The design centres the switch's snackbar at the bottom of the content area; other pages keep it on the left.
+body:has(.wc-ai-shopping) .woocommerce-transient-notices {
+ left: 50%;
+ transform: translateX(-50%);
+}
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/ai-shopping.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/ai-shopping.tsx
index 46399dc0ebe..e1ef8faf253 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/ai-shopping.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/ai-shopping.tsx
@@ -10,13 +10,15 @@ import {
} from '@wordpress/element';
import type { RefObject } from 'react';
import apiFetch from '@wordpress/api-fetch';
+import { dispatch } from '@wordpress/data';
+import { store as noticesStore } from '@wordpress/notices';
import { speak } from '@wordpress/a11y';
import { __ } from '@wordpress/i18n';
import { Page } from '@wordpress/admin-ui';
import { DataForm } from '@wordpress/dataviews';
import type { Field, Form, FormField } from '@wordpress/dataviews';
/* eslint-disable @wordpress/use-recommended-components -- The design asks for these @wordpress/ui components; this chunk bundles the package. */
-import { Button, Link, Notice, Stack, Text } from '@wordpress/ui';
+import { Button, Link, Stack, Text } from '@wordpress/ui';
/* eslint-enable @wordpress/use-recommended-components */
/**
@@ -26,9 +28,10 @@ import { safeHref } from './safe-href';
import './sales-readiness.scss';
import './ai-shopping.scss';
import type { ShoppingView } from './types';
-import { asLink, ShoppingChecklist } from './components/shopping-checklist';
+import { ShoppingChecklist } from './components/shopping-checklist';
import { ProductVisibility } from './components/product-visibility';
import { ConnectionUrl } from './components/connection-url';
+import { ComingSoonNotice } from './components/coming-soon-notice';
type Values = Record< string, string | boolean >;
@@ -140,6 +143,15 @@ const useHashTarget = (
}, [] );
};
+// The switch reloads the page after it saves, so its snackbar is shown by the page that loads next.
+const SNACKBAR_KEY = 'wc-ai-shopping-snackbar';
+
+const showSnackbar = ( text: string ) => {
+ void dispatch( noticesStore ).createSuccessNotice( text, {
+ type: 'snackbar',
+ } );
+};
+
/**
* WooCommerce > Settings > AI tools > AI shopping. The switch saves on its own; Save posts the
* settings form around this page, with the store policy fields as hidden inputs, so they save and
@@ -155,13 +167,24 @@ export default function AiShopping( { view }: { view: ShoppingView } ) {
} ) );
const [ dirty, setDirty ] = useState( false );
const [ busy, setBusy ] = useState( false );
- const [ message, setMessage ] = useState( ucp.message );
+ const [ message, setMessage ] = useState( '' );
const dirtyRef = useRef( false );
// Only clear the handler this page installed, so Save does not drop another unload listener.
const unloadHandler = useRef< ( () => string ) | null >( null );
const root = useRef< HTMLDivElement >( null );
useHashTarget( root, view );
+ useEffect( () => {
+ // Storage can be blocked; the switch's state still shows.
+ try {
+ const text = window.sessionStorage.getItem( SNACKBAR_KEY );
+ if ( text ) {
+ window.sessionStorage.removeItem( SNACKBAR_KEY );
+ showSnackbar( text );
+ }
+ } catch {}
+ }, [] );
+
useEffect( () => {
return () => {
if ( window.onbeforeunload === unloadHandler.current ) {
@@ -199,13 +222,18 @@ export default function AiShopping( { view }: { view: ShoppingView } ) {
...current,
enabled: response.enabled,
} ) );
+ const done = response.enabled ? ucp.turned_on : ucp.turned_off;
// The checklist and the other cards depend on the switch, so the page reloads,
// unless that would lose unsaved fields.
if ( dirtyRef.current ) {
+ showSnackbar( done );
say( ucp.unsaved );
setBusy( false );
return;
}
+ try {
+ window.sessionStorage.setItem( SNACKBAR_KEY, done );
+ } catch {}
// Not reload(): after Save, that would post the settings form again.
window.location.assign(
window.location.href.split( '#' )[ 0 ]
@@ -291,20 +319,7 @@ export default function AiShopping( { view }: { view: ShoppingView } ) {
isVisible: () => view.coming_soon !== null,
render: () =>
view.coming_soon && (
- <Notice.Root intent="warning">
- <Notice.Description>
- { view.coming_soon.text }
- </Notice.Description>
- <Notice.Actions>
- <Notice.ActionButton
- variant="outline"
- className="wc-ai-shopping__notice-action"
- { ...asLink( view.coming_soon.link.href ) }
- >
- { view.coming_soon.link.text }
- </Notice.ActionButton>
- </Notice.Actions>
- </Notice.Root>
+ <ComingSoonNotice notice={ view.coming_soon } />
),
},
{
@@ -410,6 +425,7 @@ export default function AiShopping( { view }: { view: ShoppingView } ) {
actions={
<Button
variant="solid"
+ className="wc-sales-readiness-ui-button"
type="submit"
form="mainform"
name="save"
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/components/as-link.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/components/as-link.tsx
new file mode 100644
index 00000000000..532f111b0d7
--- /dev/null
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/components/as-link.tsx
@@ -0,0 +1,24 @@
+/**
+ * Internal dependencies
+ */
+import { safeHref } from '../safe-href';
+
+/**
+ * Props that make a @wordpress/ui Button a link, or that disable it when the URL is rejected.
+ * This version of the package has no ButtonLink.
+ *
+ * @param href Link from the view.
+ */
+export const asLink = ( href: string ) => {
+ const safe = safeHref( href );
+ if ( ! safe ) {
+ return { disabled: true };
+ }
+ return {
+ nativeButton: false as const,
+ role: 'link' as const,
+ // The Button renders the text into it.
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
+ render: <a href={ safe } />,
+ };
+};
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/components/check-row.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/components/check-row.tsx
index 637c2bfb551..5f27e6a1d6c 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/components/check-row.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/components/check-row.tsx
@@ -3,6 +3,7 @@
*/
import { Badge, Icon, Link, Stack, Text, VisuallyHidden } from '@wordpress/ui';
import { Button } from '@wordpress/components';
+import { useInstanceId } from '@wordpress/compose';
import { Path, SVG } from '@wordpress/primitives';
import { createInterpolateElement } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
@@ -12,9 +13,30 @@ import type { ReactNode } from 'react';
* Internal dependencies
*/
import { safeHref } from '../safe-href';
-import type { CheckRow as CheckRowData, ViewBadge, ViewLink } from '../types';
+import type {
+ CheckRow as CheckRowData,
+ TextLink,
+ ViewBadge,
+ ViewLink,
+} from '../types';
import { trackReadiness, type Surface } from '../tracks';
+/**
+ * A shared button text such as "Edit page" keeps its accessible name, so voice control finds it by what
+ * it shows (WCAG 2.5.3); screen readers also hear which policy it is for, as its description.
+ *
+ * @param sr The button's full action, such as "Edit your refund and returns policy page", or none.
+ */
+export const useSrDescription = ( sr?: string ) => {
+ const id = useInstanceId( useSrDescription, 'wc-sales-readiness-sr' );
+ return sr
+ ? {
+ props: { 'aria-describedby': id },
+ description: <VisuallyHidden id={ id }>{ sr }</VisuallyHidden>,
+ }
+ : { props: {}, description: null };
+};
+
/**
* Where to fix it: an outline button when it has a URL, plain text otherwise.
*/
@@ -26,15 +48,20 @@ export const RowLink = ( {
onClick?: () => void;
} ) => {
const href = safeHref( link.href );
+ const sr = useSrDescription( link.sr );
return href ? (
- <Button
- variant="secondary"
- size="compact"
- href={ href }
- onClick={ onClick }
- >
- { link.text }
- </Button>
+ <>
+ <Button
+ variant="secondary"
+ size="compact"
+ href={ href }
+ onClick={ onClick }
+ { ...sr.props }
+ >
+ { link.text }
+ </Button>
+ { sr.description }
+ </>
) : (
<Text variant="body-sm" className="wc-sales-readiness__muted">
{ link.text }
@@ -183,9 +210,16 @@ const TextWithLink = ( {
link,
}: {
text: string;
- link?: ViewLink | null;
+ link?: TextLink | null;
} ) => {
- const at = link?.text ? text.indexOf( link.text ) : -1;
+ // The server says where the name starts, so a name that also appears earlier isn't linked there.
+ let at = link?.text ? text.indexOf( link.text ) : -1;
+ if (
+ link?.at !== undefined &&
+ text.slice( link.at, link.at + link.text.length ) === link.text
+ ) {
+ at = link.at;
+ }
if ( ! link || at < 0 ) {
return <>{ text }</>;
}
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/components/checked-card.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/components/checked-card.tsx
index 1d6100b5a83..31f6fc797bc 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/components/checked-card.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/components/checked-card.tsx
@@ -1,8 +1,10 @@
/**
* External dependencies
*/
-import { Card, Link, Text } from '@wordpress/ui';
-import { Button } from '@wordpress/components';
+/* eslint-disable @wordpress/use-recommended-components -- The design asks for these @wordpress/ui components; this chunk bundles the package. */
+import { Button, Card, Link, Text } from '@wordpress/ui';
+/* eslint-enable @wordpress/use-recommended-components */
+import { Spinner } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
@@ -21,75 +23,86 @@ interface CheckedCardProps {
}
/**
- * When the store was last checked, with Check again, then Need help? with the results to
- * download for support (built from the last check), from the first check on. Before the first check it says what a
- * check shows and offers Run check.
+ * When the store was last checked, with Check again. Before the first check it says Not checked
+ * yet and offers Check your store. While a check runs it shows a spinner and Checking your store,
+ * with Check again turned off. From the first check on, Need help? offers the results to
+ * download for support (built from the last check).
*/
export const CheckedCard = ( {
view,
running,
onRun,
onDownloadError,
-}: CheckedCardProps ) => (
- <Card.Root className="wc-sales-readiness-card">
- <Card.Content>
- { view.intro && (
- <Text
- variant="body-md"
- className="wc-sales-readiness-checked__intro"
- >
- { view.intro }
- </Text>
- ) }
- <div className="wc-sales-readiness-checked">
- <div>
- <Text variant="body-md">{ view.last_checked }</Text>
- { view.checked_note && (
- <Text
- variant="body-sm"
- className="wc-sales-readiness__muted"
+}: CheckedCardProps ) => {
+ const checking = ( view.run.pending && ! view.run.stalled ) || running;
+ return (
+ <Card.Root className="wc-sales-readiness-card">
+ <Card.Content>
+ <div className="wc-sales-readiness-checked">
+ { checking ? (
+ <div
+ className="wc-sales-readiness-checked__running"
+ role="status"
>
- { view.checked_note }
- </Text>
- ) }
- { ! view.intro && (
- <Text
- variant="body-sm"
- className="wc-sales-readiness__muted"
- >
- { createInterpolateElement(
- __(
- 'Need help? <download>Download your results</download> and <support>contact support</support>.',
- 'woocommerce'
- ),
- {
- download: (
- <SupportDownload
- onError={ onDownloadError }
- />
- ),
- support: (
- <Link
- href={ view.support_url }
- openInNewTab
- />
- ),
- }
+ <Spinner />
+ <Text variant="body-md">
+ { view.run.message ||
+ __( 'Checking your store', 'woocommerce' ) }
+ </Text>
+ </div>
+ ) : (
+ <div>
+ <Text variant="body-md">{ view.last_checked }</Text>
+ { view.checked_note && (
+ <Text
+ variant="body-sm"
+ className="wc-sales-readiness__muted"
+ >
+ { view.checked_note }
+ </Text>
+ ) }
+ { view.checked && (
+ <Text
+ variant="body-sm"
+ className="wc-sales-readiness__muted"
+ >
+ { createInterpolateElement(
+ __(
+ 'Need help? <download>Download your results</download> and <support>contact support</support>.',
+ 'woocommerce'
+ ),
+ {
+ download: (
+ <SupportDownload
+ onError={ onDownloadError }
+ />
+ ),
+ support: (
+ <Link
+ href={ view.support_url }
+ openInNewTab
+ />
+ ),
+ }
+ ) }
+ </Text>
) }
- </Text>
+ </div>
) }
+ <Button
+ variant="outline"
+ size="compact"
+ className="wc-sales-readiness-ui-button"
+ disabled={ view.run.pending || running }
+ onClick={ onRun }
+ >
+ { checking
+ ? __( 'Check again', 'woocommerce' )
+ : view.run.label }
+ </Button>
</div>
- <Button
- variant="secondary"
- size="compact"
- disabled={ view.run.pending || running }
- isBusy={ running }
- onClick={ onRun }
- >
- { view.run.label }
- </Button>
- </div>
- <RunStatus run={ view.run } />
- </Card.Content>
- </Card.Root>
-);
+ { ! checking && <RunStatus run={ view.run } /> }
+ </Card.Content>
+ </Card.Root>
+ );
+};
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/components/coming-soon-notice.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/components/coming-soon-notice.tsx
new file mode 100644
index 00000000000..67550928cfa
--- /dev/null
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/components/coming-soon-notice.tsx
@@ -0,0 +1,35 @@
+/**
+ * External dependencies
+ */
+/* eslint-disable @wordpress/use-recommended-components -- The design asks for these @wordpress/ui components; this chunk bundles the package. */
+import { Notice } from '@wordpress/ui';
+/* eslint-enable @wordpress/use-recommended-components */
+
+/**
+ * Internal dependencies
+ */
+import type { ViewLink } from '../types';
+import { asLink } from './as-link';
+
+/**
+ * The warning that the store is in coming soon mode, with a link to its visibility settings.
+ * AI shopping and AI shopping health show the same notice.
+ */
+export const ComingSoonNotice = ( {
+ notice,
+}: {
+ notice: { text: string; link: ViewLink };
+} ) => (
+ <Notice.Root intent="warning">
+ <Notice.Description>{ notice.text }</Notice.Description>
+ <Notice.Actions>
+ <Notice.ActionButton
+ variant="outline"
+ className="wc-ai-shopping__notice-action wc-sales-readiness-ui-button"
+ { ...asLink( notice.link.href ) }
+ >
+ { notice.link.text }
+ </Notice.ActionButton>
+ </Notice.Actions>
+ </Notice.Root>
+);
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/components/connection-url.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/components/connection-url.tsx
index e06fc186f1d..5450e493878 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/components/connection-url.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/components/connection-url.tsx
@@ -48,7 +48,11 @@ export const ConnectionUrl = ( {
readOnly
value={ connection.url }
/>
- <Button variant="outline" onClick={ copy }>
+ <Button
+ variant="outline"
+ className="wc-sales-readiness-ui-button"
+ onClick={ copy }
+ >
{ copied ? connection.copied : connection.copy }
</Button>
</div>
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/components/shopping-checklist.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/components/shopping-checklist.tsx
index 3a58da37ef7..15093664fa1 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/components/shopping-checklist.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/components/shopping-checklist.tsx
@@ -10,28 +10,38 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
-import { safeHref } from '../safe-href';
import type { ShoppingView } from '../types';
-import { Row } from './check-row';
+import { asLink } from './as-link';
+import { Row, useSrDescription } from './check-row';
type Checklist = ShoppingView[ 'checklist' ];
/**
- * Props that make a @wordpress/ui Button a link, or that disable it when the URL is rejected.
- * This version of the package has no ButtonLink.
+ * A step's button, with the policy it is for read as its description.
+ *
+ * @param props Props.
+ * @param props.link The step's link.
*/
-export const asLink = ( href: string ) => {
- const safe = safeHref( href );
- if ( ! safe ) {
- return { disabled: true };
- }
- return {
- nativeButton: false as const,
- role: 'link' as const,
- // The Button renders the text into it.
- // eslint-disable-next-line jsx-a11y/anchor-has-content
- render: <a href={ safe } />,
- };
+const StepButton = ( {
+ link,
+}: {
+ link: NonNullable< Checklist[ 'steps' ][ number ][ 'link' ] >;
+} ) => {
+ const sr = useSrDescription( link.sr );
+ return (
+ <>
+ <Button
+ variant="outline"
+ size="compact"
+ className="wc-sales-readiness-ui-button"
+ { ...asLink( link.href ) }
+ { ...sr.props }
+ >
+ { link.text }
+ </Button>
+ { sr.description }
+ </>
+ );
};
/**
@@ -67,16 +77,7 @@ export const ShoppingChecklist = ( {
badge={ step.badge }
srState={ issue }
action={
- step.link && (
- <Button
- variant="outline"
- size="compact"
- { ...asLink( step.link.href ) }
- aria-label={ step.link.sr || undefined }
- >
- { step.link.text }
- </Button>
- )
+ step.link && <StepButton link={ step.link } />
}
>
{ step.lines.map( ( line ) => (
@@ -118,7 +119,13 @@ export const ShoppingChecklist = ( {
</ul>
</Collapsible.Panel>
<Collapsible.Trigger
- render={ <Button variant="minimal" size="compact" /> }
+ render={
+ <Button
+ variant="minimal"
+ size="compact"
+ className="wc-sales-readiness-ui-button"
+ />
+ }
>
{ open ? checklist.hide_done : checklist.show_done }
</Collapsible.Trigger>
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/index.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/index.tsx
index dd6726062ad..cf532acae7e 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/index.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/index.tsx
@@ -12,6 +12,7 @@ import { __ } from '@wordpress/i18n';
import './sales-readiness.scss';
import { useReadinessView } from './use-readiness-view';
import { CheckedCard } from './components/checked-card';
+import { ComingSoonNotice } from './components/coming-soon-notice';
import { ErrorNotice } from './components/error-notice';
import { FixFirstCard } from './components/fix-first';
import { DeclaredCard, SectionCard } from './components/section-card';
@@ -60,6 +61,9 @@ export default function SalesReadiness() {
onRun={ runCheck }
onDownloadError={ setDownloadError }
/>
+ { view.coming_soon && (
+ <ComingSoonNotice notice={ view.coming_soon } />
+ ) }
{ view.fix_first && (
<FixFirstCard fixFirst={ view.fix_first } />
) }
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/overview.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/overview.tsx
index 138307dafb0..ecd231e88ee 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/overview.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/overview.tsx
@@ -125,7 +125,7 @@ export default function SalesReadinessOverview( {
{ view.overview.based_on &&
' ' + view.overview.based_on }
</Text>
- { view.intro ? (
+ { ! view.checked ? (
<>
<Text
variant="body-sm"
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/sales-readiness.scss b/plugins/woocommerce/client/admin/client/sales-readiness/sales-readiness.scss
index 449f337a614..e671bd1cd7e 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/sales-readiness.scss
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/sales-readiness.scss
@@ -1,5 +1,17 @@
// Sales readiness page and the AI tools Overview. Tokens from the design system; the build injects their fallbacks.
+// WordPress UI buttons are semibold in the design; the version bundled here sets medium (499).
+// The element in the selector outweighs the button's own class, whichever stylesheet loads last.
+:is(button, a).wc-sales-readiness-ui-button {
+ font-weight: 600;
+}
+
+// The coming soon notice's button is a link, so wp-admin's link blue would override the neutral button's label.
+.wc-ai-shopping__notice-action,
+.wc-ai-shopping__notice-action:is(:hover, :focus, :active) {
+ color: var(--wpds-color-foreground-interactive-neutral);
+}
+
// The prototype's buttons (WordPress UI minimal and outline): semibold, and a light background
// on hover and focus that stays after a click until focus moves; the focus ring only for keyboard focus.
@mixin sales-readiness-button($padding: var(--wpds-dimension-padding-md)) {
@@ -68,6 +80,12 @@ body:has(.wc-sales-readiness) {
color: var(--wpds-color-foreground-content-neutral);
+ // The AI shopping health page's background reaches the bottom of the screen, also when the cards are
+ // short. Not the Overview and AI shopping panels, which sit inside the settings form.
+ &:not(.wc-sales-readiness--overview):not(.wc-ai-shopping) {
+ min-height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
+ }
+
&__content {
box-sizing: border-box;
width: 100%;
@@ -418,23 +436,19 @@ body:has(.wc-sales-readiness) {
gap: 2px;
}
- &__intro {
- display: block;
- margin-block-end: var(--wpds-dimension-gap-md);
- }
-
- // Check again: an outline button.
- > .components-button {
- @include sales-readiness-button;
- border-color: var(--wpds-color-stroke-interactive-brand);
+ > .wc-sales-readiness-checked__running {
+ flex-direction: row;
+ align-items: center;
+ gap: var(--wpds-dimension-gap-md);
- &:not(:disabled):is(:hover, :active, :focus) {
- border-color: var(--wpds-color-stroke-interactive-brand-active);
+ .components-spinner {
+ margin: 0;
}
+ }
- &:disabled {
- border-color: var(--wpds-color-stroke-interactive-brand-disabled);
- }
+ > button {
+ flex-shrink: 0;
+ white-space: nowrap;
}
}
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/test/ai-shopping.test.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/test/ai-shopping.test.tsx
index 7975a0eed99..c2315b948a7 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/test/ai-shopping.test.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/test/ai-shopping.test.tsx
@@ -18,6 +18,11 @@ import type { ShoppingView } from '../types';
jest.mock( '@wordpress/api-fetch', () => jest.fn() );
jest.mock( '@wordpress/a11y', () => ( { speak: jest.fn() } ) );
+const mockCreateSuccessNotice = jest.fn();
+jest.mock( '@wordpress/data', () => ( {
+ ...jest.requireActual( '@wordpress/data' ),
+ dispatch: () => ( { createSuccessNotice: mockCreateSuccessNotice } ),
+} ) );
const mockedFetch = apiFetch as unknown as jest.Mock;
@@ -54,8 +59,12 @@ const view = ( fields: Partial< ShoppingView > = {} ): ShoppingView => ( {
blocked: true,
title: 'Allow AI assistants to shop your store',
description: 'Your products can be found by AI assistants.',
- learn_more: { href: 'https://ucp.dev/', text: 'Learn how it works' },
- message: '',
+ learn_more: {
+ href: 'https://woocommerce.com/document/woocommerce-ai/agentic-commerce/',
+ text: 'Learn how it works',
+ },
+ turned_on: 'AI assistants can now shop your store.',
+ turned_off: 'AI assistants can no longer shop your store.',
path: '/wc/v3/agent-readiness/ucp',
error_on:
'AI shopping wasn’t turned on. Reload the page and try again.',
@@ -161,6 +170,8 @@ describe( 'AiShopping', () => {
beforeEach( () => {
mockedFetch.mockReset();
+ mockCreateSuccessNotice.mockReset();
+ window.sessionStorage.clear();
Object.defineProperty( window, 'location', {
configurable: true,
value: {
@@ -234,11 +245,15 @@ describe( 'AiShopping', () => {
} )
);
- expect(
- screen.getByRole( 'link', {
- name: 'Edit your refund and returns policy page',
- } )
- ).toHaveAttribute( 'href', '/post.php?post=5&action=edit' );
+ const link = screen.getByRole( 'link', {
+ name: 'Edit page',
+ description: 'Edit your refund and returns policy page',
+ } );
+ expect( link ).toHaveAccessibleName( 'Edit page' );
+ expect( link ).toHaveAttribute(
+ 'href',
+ '/post.php?post=5&action=edit'
+ );
expect( screen.queryByText( 'Required' ) ).toBeNull();
} );
@@ -273,8 +288,6 @@ describe( 'AiShopping', () => {
...view().ucp,
enabled: true,
blocked: false,
- message:
- 'AI shopping is on. AI assistants can now find and shop your store.',
},
checklist: {
...view().checklist,
@@ -287,11 +300,7 @@ describe( 'AiShopping', () => {
expect( toggle() ).toBeChecked();
expect( toggle() ).not.toBeDisabled();
- expect(
- screen.getByText(
- 'AI shopping is on. AI assistants can now find and shop your store.'
- )
- ).toBeInTheDocument();
+ expect( screen.queryByText( /can now shop/ ) ).toBeNull();
expect( screen.queryByText( /step left/ ) ).toBeNull();
fireEvent.click(
@@ -434,6 +443,27 @@ describe( 'AiShopping', () => {
expect( window.location.assign ).toHaveBeenCalledWith(
'https://example.com/wp-admin/admin.php?page=wc-settings'
);
+ expect(
+ window.sessionStorage.getItem( 'wc-ai-shopping-snackbar' )
+ ).toBe( 'AI assistants can now shop your store.' );
+ expect( mockCreateSuccessNotice ).not.toHaveBeenCalled();
+ } );
+
+ it( 'shows the switch’s snackbar on the page that loads after it saves, once', () => {
+ window.sessionStorage.setItem(
+ 'wc-ai-shopping-snackbar',
+ 'AI assistants can no longer shop your store.'
+ );
+ renderPage( view() );
+
+ expect( mockCreateSuccessNotice ).toHaveBeenCalledTimes( 1 );
+ expect( mockCreateSuccessNotice ).toHaveBeenCalledWith(
+ 'AI assistants can no longer shop your store.',
+ { type: 'snackbar' }
+ );
+ expect(
+ window.sessionStorage.getItem( 'wc-ai-shopping-snackbar' )
+ ).toBeNull();
} );
it( 'does not reload over unsaved fields, and says to save them', async () => {
@@ -454,6 +484,10 @@ describe( 'AiShopping', () => {
expect( window.location.assign ).not.toHaveBeenCalled();
expect( toggle() ).not.toBeChecked();
+ expect( mockCreateSuccessNotice ).toHaveBeenCalledWith(
+ 'AI assistants can no longer shop your store.',
+ { type: 'snackbar' }
+ );
expect(
screen.getByText( 'Save your changes to see the updated status.' )
).toBeInTheDocument();
@@ -525,7 +559,10 @@ describe( 'AiShopping', () => {
).toHaveAttribute( 'href', 'https://ucpplayground.com' );
expect(
screen.getByRole( 'link', { name: /Learn how it works/ } )
- ).toHaveAttribute( 'href', 'https://ucp.dev/' );
+ ).toHaveAttribute(
+ 'href',
+ 'https://woocommerce.com/document/woocommerce-ai/agentic-commerce/'
+ );
} );
it( 'goes to a policy field from a link, on load and from the Setup checklist on this page', () => {
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/test/as-link.test.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/test/as-link.test.tsx
index 9ebfb466ee2..dc13aba9c71 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/test/as-link.test.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/test/as-link.test.tsx
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
-import { asLink } from '../components/shopping-checklist';
+import { asLink } from '../components/as-link';
describe( 'asLink', () => {
it( 'disables the button when the URL is rejected', () => {
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/test/check-row.test.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/test/check-row.test.tsx
index 8cc2e349fe8..934abc58726 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/test/check-row.test.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/test/check-row.test.tsx
@@ -93,6 +93,63 @@ describe( 'CheckRow', () => {
);
} );
+ it( 'links the name where the server says it starts, not where the same word appears first', () => {
+ const { container } = renderRow(
+ row( {
+ id: 'product_jsonld_present',
+ text: 'On the the page, the name, price, and stock aren’t in the page code.',
+ text_link: {
+ href: 'https://example.com/product/the/',
+ text: 'the',
+ at: 7,
+ },
+ } )
+ );
+
+ const link = screen.getByRole( 'link', { name: /the/ } );
+ expect( link.previousSibling?.textContent ).toBe( 'On the ' );
+ expect( container ).toHaveTextContent(
+ 'On the the page, the name, price, and stock aren’t in the page code.'
+ );
+ } );
+
+ it( 'links the name at a UTF-16 offset when an emoji comes first', () => {
+ const { container } = renderRow(
+ row( {
+ id: 'product_jsonld_present',
+ text: '😀 On the the page, the name.',
+ text_link: {
+ href: 'https://example.com/product/the/',
+ text: 'the',
+ at: 10,
+ },
+ } )
+ );
+
+ const link = screen.getByRole( 'link', { name: /the/ } );
+ expect( link.previousSibling?.textContent ).toBe( '😀 On the ' );
+ expect( container ).toHaveTextContent(
+ '😀 On the the page, the name.'
+ );
+ } );
+
+ it( 'falls back to the first match when the position does not hold the name', () => {
+ renderRow(
+ row( {
+ text: 'Test it in UCP Playground, or ask your hosting provider.',
+ text_link: {
+ href: 'https://ucpplayground.com/',
+ text: 'UCP Playground',
+ at: 0,
+ },
+ } )
+ );
+
+ expect(
+ screen.getByRole( 'link', { name: /UCP Playground/ } )
+ ).toBeInTheDocument();
+ } );
+
it( 'shows the text unlinked when the name is not in it', () => {
renderRow(
row( {
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/test/checked-card.test.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/test/checked-card.test.tsx
new file mode 100644
index 00000000000..1f11f82ce63
--- /dev/null
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/test/checked-card.test.tsx
@@ -0,0 +1,134 @@
+/**
+ * External dependencies
+ */
+import { render, screen } from '@testing-library/react';
+
+/**
+ * Internal dependencies
+ */
+import { CheckedCard } from '../components/checked-card';
+import { RowLink } from '../components/check-row';
+import type { ReadinessView } from '../types';
+
+const firstVisit = {
+ last_checked: 'Not checked yet',
+ checked_note: null,
+ checked: false,
+ run: {
+ label: 'Check your store',
+ pending: false,
+ stalled: false,
+ message: '',
+ link: null,
+ },
+} as unknown as ReadinessView;
+
+describe( 'CheckedCard', () => {
+ it( 'shows Not checked yet and Check your store on the first visit, without the intro', () => {
+ render(
+ <CheckedCard
+ view={ firstVisit }
+ running={ false }
+ onRun={ jest.fn() }
+ onDownloadError={ jest.fn() }
+ />
+ );
+ expect( screen.getByText( 'Not checked yet' ) ).toBeInTheDocument();
+ expect(
+ screen.getByRole( 'button', { name: 'Check your store' } )
+ ).toBeEnabled();
+ expect(
+ screen.queryByText( 'Run a check to see what AI assistants get.' )
+ ).toBeNull();
+ } );
+
+ it( 'shows a spinner, Checking your store and a turned-off Check again while a check runs', () => {
+ const running = {
+ ...firstVisit,
+ run: {
+ ...firstVisit.run,
+ pending: true,
+ message: 'Checking your store',
+ },
+ };
+ const { container } = render(
+ <CheckedCard
+ view={ running }
+ running={ false }
+ onRun={ jest.fn() }
+ onDownloadError={ jest.fn() }
+ />
+ );
+ expect(
+ container.querySelector( '.components-spinner' )
+ ).not.toBeNull();
+ expect( screen.getByRole( 'status' ) ).toHaveTextContent(
+ 'Checking your store'
+ );
+ expect( screen.queryByText( 'Not checked yet' ) ).toBeNull();
+ // Turned off but still focusable, so focus stays on it after the click.
+ expect(
+ screen.getByRole( 'button', { name: 'Check again' } )
+ ).toHaveAttribute( 'aria-disabled', 'true' );
+ } );
+
+ it( 'shows the stalled message, not a spinner, when the check cannot start', () => {
+ const stalled = {
+ ...firstVisit,
+ run: {
+ ...firstVisit.run,
+ pending: true,
+ stalled: true,
+ message:
+ 'Checks can’t start because scheduled actions aren’t running.',
+ },
+ };
+ const { container } = render(
+ <CheckedCard
+ view={ stalled }
+ running={ false }
+ onRun={ jest.fn() }
+ onDownloadError={ jest.fn() }
+ />
+ );
+
+ expect( container.querySelector( '.components-spinner' ) ).toBeNull();
+ expect( screen.getByRole( 'status' ) ).toHaveTextContent(
+ 'Checks can’t start'
+ );
+ } );
+
+ it( 'shows the running state as soon as Check your store is clicked', () => {
+ render(
+ <CheckedCard
+ view={ firstVisit }
+ running={ true }
+ onRun={ jest.fn() }
+ onDownloadError={ jest.fn() }
+ />
+ );
+ expect( screen.getByRole( 'status' ) ).toHaveTextContent(
+ 'Checking your store'
+ );
+ } );
+} );
+
+describe( 'RowLink', () => {
+ it( 'gives a repeated button text the name screen readers hear', () => {
+ render(
+ <RowLink
+ link={ {
+ href: 'https://example.com/wp-admin/post.php?post=7&action=edit',
+ text: 'Edit page',
+ sr: 'Edit your refund and returns policy page',
+ } }
+ />
+ );
+ const link = screen.getByRole( 'link', {
+ name: 'Edit page',
+ description: 'Edit your refund and returns policy page',
+ } );
+ expect( link ).toHaveAccessibleName( 'Edit page' );
+ expect( link ).toHaveTextContent( 'Edit page' );
+ } );
+} );
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/test/support-download.test.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/test/support-download.test.tsx
index 212fc1e47fc..de36a387ec3 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/test/support-download.test.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/test/support-download.test.tsx
@@ -82,11 +82,11 @@ describe( 'SupportDownload', () => {
} );
describe( 'CheckedCard', () => {
- const checked = ( intro: string | null ) =>
+ const checked = ( hasRun: boolean ) =>
( {
last_checked: 'Last checked today',
checked_note: null,
- intro,
+ checked: hasRun,
support_url: 'https://woocommerce.com/my-account/create-a-ticket/',
run: {
label: 'Check again',
@@ -97,10 +97,10 @@ describe( 'CheckedCard', () => {
},
} ) as unknown as ReadinessView;
- const renderCard = ( intro: string | null ) =>
+ const renderCard = ( hasRun: boolean ) =>
render(
<CheckedCard
- view={ checked( intro ) }
+ view={ checked( hasRun ) }
running={ false }
onRun={ jest.fn() }
onDownloadError={ jest.fn() }
@@ -108,7 +108,7 @@ describe( 'CheckedCard', () => {
);
it( 'offers Need help? with the results to download and a link to support', () => {
- renderCard( null );
+ renderCard( true );
expect(
screen.getByText( /^Need help\?/ ).closest( 'span' )
@@ -127,7 +127,7 @@ describe( 'CheckedCard', () => {
} );
it( 'shows no Need help? line before the first check, as in the design', () => {
- renderCard( 'Run a check to see what AI assistants get.' );
+ renderCard( false );
expect(
screen.queryByRole( 'button', { name: 'Download your results' } )
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/test/tracks.test.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/test/tracks.test.tsx
index 7e97ced48fd..6ce3fce1bbe 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/test/tracks.test.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/test/tracks.test.tsx
@@ -24,7 +24,7 @@ const checkedView: ReadinessView = {
description: 'See how AI assistants see your store.',
last_checked: 'Last checked today',
checked_note: null,
- intro: null,
+ checked: true,
run: {
label: 'Check again',
pending: false,
@@ -33,6 +33,7 @@ const checkedView: ReadinessView = {
link: null,
},
support_url: 'https://woocommerce.com/my-account/create-a-ticket/',
+ coming_soon: null,
fix_first: {
title: 'Fix first',
ranking: 'Ranked by products.',
@@ -186,9 +187,7 @@ describe( 'Sales readiness tracking', () => {
it( 'records Run checks, without a second viewed event after the reload', async () => {
mockedApiFetch.mockImplementation( ( { method } ) =>
Promise.resolve(
- method === 'POST'
- ? {}
- : { ...checkedView, intro: 'Run a check.' }
+ method === 'POST' ? {} : { ...checkedView, checked: false }
)
);
render( <SalesReadiness /> );
@@ -366,7 +365,7 @@ describe( 'Sales readiness tracking', () => {
it( 'keeps the Overview cards when starting a check fails', async () => {
const first = {
...checkedView,
- intro: 'Run a check.',
+ checked: false,
fix_first: null,
run: {
label: 'Run checks',
@@ -474,4 +473,33 @@ describe( 'Sales readiness page', () => {
screen.queryByText( 'Ranked by products.' )
).not.toBeInTheDocument();
} );
+
+ it( 'shows the coming soon notice above Fix first', async () => {
+ mockedApiFetch.mockResolvedValue( {
+ ...checkedView,
+ coming_soon: {
+ text: 'Your store is in coming soon mode.',
+ link: {
+ href: 'https://example.com/wp-admin/admin.php?page=wc-settings&tab=site-visibility',
+ text: 'Change store visibility',
+ },
+ },
+ } );
+ render( <SalesReadiness /> );
+
+ const notice = await screen.findByText(
+ 'Your store is in coming soon mode.'
+ );
+ expect(
+ screen.getByRole( 'link', { name: 'Change store visibility' } )
+ ).toHaveAttribute(
+ 'href',
+ 'https://example.com/wp-admin/admin.php?page=wc-settings&tab=site-visibility'
+ );
+ expect(
+ // eslint-disable-next-line no-bitwise
+ notice.compareDocumentPosition( screen.getByText( 'Fix first' ) ) &
+ window.Node.DOCUMENT_POSITION_FOLLOWING
+ ).toBeTruthy();
+ } );
} );
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/test/use-readiness-view.test.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/test/use-readiness-view.test.tsx
index f0f50744475..f3020aae8d7 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/test/use-readiness-view.test.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/test/use-readiness-view.test.tsx
@@ -203,11 +203,11 @@ describe( 'RunStatus', () => {
it( 'shows no spinner while a check runs, only its message for screen readers', () => {
const { container } = render(
- <RunStatus run={ run( true, false, 'Checking your store.' ) } />
+ <RunStatus run={ run( true, false, 'Checking your store' ) } />
);
expect( container.querySelector( '.components-spinner' ) ).toBeNull();
expect( screen.getByRole( 'status' ) ).toHaveTextContent(
- 'Checking your store.'
+ 'Checking your store'
);
expect(
container.querySelector( '.wc-sales-readiness__muted' )
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/tracks.ts b/plugins/woocommerce/client/admin/client/sales-readiness/tracks.ts
index 539ecbbea1a..cc0b980b7a6 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/tracks.ts
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/tracks.ts
@@ -42,7 +42,7 @@ export function viewedProps( view: ReadinessView, surface: Surface ): Props {
}
return {
surface,
- checked: ! view.intro,
+ checked: view.checked,
pending: view.run.pending,
fix_first_count: view.fix_first?.items.length ?? 0,
open_count: counts.open,
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/types.ts b/plugins/woocommerce/client/admin/client/sales-readiness/types.ts
index b0059985148..f5483efe40e 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/types.ts
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/types.ts
@@ -15,6 +15,13 @@ export interface ViewLink {
/** Empty when the text is shown without a link. */
href: string;
text: string;
+ /** What screen readers also hear, as the button's description, when the text repeats (Edit page). */
+ sr?: string;
+}
+
+/** A name to link inside a line, and where it starts when it could also appear earlier. */
+export interface TextLink extends ViewLink {
+ at?: number;
}
export type RowState = 'open' | 'required' | 'unknown' | 'pass';
@@ -34,7 +41,7 @@ export interface CheckRow {
link: ViewLink | null;
seen_at: ViewLink | null;
/** A name in the text to link, such as a tool to test with. */
- text_link?: ViewLink | null;
+ text_link?: TextLink | null;
}
export interface FixFirstItem {
@@ -101,7 +108,8 @@ export interface ReadinessView {
description: string;
last_checked: string;
checked_note: string | null;
- intro: string | null;
+ /** False before the first check. */
+ checked: boolean;
run: {
label: string;
pending: boolean;
@@ -112,6 +120,8 @@ export interface ReadinessView {
};
/** Where Need help? sends merchants: WordPress.com support on WordPress.com, else WooCommerce.com. */
support_url: string;
+ /** While the store is in coming soon mode and the results are from when it was live. */
+ coming_soon: { text: string; link: ViewLink } | null;
/** Null before the first check, and when there is nothing to fix. */
fix_first: FixFirst | null;
sections: Section[];
@@ -174,8 +184,9 @@ export interface ShoppingView {
title: string;
description: string;
learn_more: ViewLink;
- /** What the switch says under it: that AI shopping is on, or ''. */
- message: string;
+ /** The snackbar after the switch saves, turned on and turned off. */
+ turned_on: string;
+ turned_off: string;
path: string;
/** Said when turning AI shopping on didn't save, unless required steps are the reason. */
error_on: string;
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/use-readiness-view.ts b/plugins/woocommerce/client/admin/client/sales-readiness/use-readiness-view.ts
index 32a4651256a..88fc1472e30 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/use-readiness-view.ts
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/use-readiness-view.ts
@@ -113,7 +113,7 @@ export function useReadinessView(
const runCheck = useCallback( async () => {
trackReadiness( 'run_check_clicked', {
surface,
- first_check: !! view?.intro,
+ first_check: !! view && ! view.checked,
} );
setRunning( true );
try {
@@ -130,7 +130,7 @@ export function useReadinessView(
} finally {
setRunning( false );
}
- }, [ load, surface, view?.intro ] );
+ }, [ load, surface, view?.checked ] );
return { view, error, reload, running, runCheck };
}
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/AgenticCommerceSettingsPage.php b/plugins/woocommerce/src/Internal/AgentReadiness/AgenticCommerceSettingsPage.php
index 52e95829530..2a06118066f 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/AgenticCommerceSettingsPage.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/AgenticCommerceSettingsPage.php
@@ -237,10 +237,12 @@ class AgenticCommerceSettingsPage extends \WC_Settings_Page {
'title' => __( 'Allow AI assistants to shop your store', 'woocommerce' ),
'description' => __( 'Your products can be found by AI assistants and added to a shopper’s cart. Orders come through your checkout as usual.', 'woocommerce' ),
'learn_more' => array(
- 'href' => 'https://ucp.dev/',
+ 'href' => 'https://woocommerce.com/document/woocommerce-ai/agentic-commerce/',
'text' => __( 'Learn how it works', 'woocommerce' ),
),
- 'message' => ( $enabled && array() === $failing ) ? __( 'AI shopping is on. AI assistants can now find and shop your store.', 'woocommerce' ) : '',
+ // The snackbar after the switch saves, as in the design.
+ 'turned_on' => __( 'AI assistants can now shop your store.', 'woocommerce' ),
+ 'turned_off' => __( 'AI assistants can no longer shop your store.', 'woocommerce' ),
'path' => '/wc/v3/agent-readiness/ucp',
// Shown when the switch didn't save, unless the reason is required steps that aren't done.
'error_on' => __( 'AI shopping wasn’t turned on. Reload the page and try again.', 'woocommerce' ),
@@ -402,7 +404,7 @@ class AgenticCommerceSettingsPage extends \WC_Settings_Page {
* @return array<string, mixed>
*/
private static function checklist( array $checks ): array {
- $done = array_filter( $checks, static fn( array $check ): bool => 'ucp_on' !== $check['id'] && $check['ok'] );
+ $done = ReadinessCheckPage::done_steps( $checks );
$open = ReadinessCheckPage::open_steps( $checks );
$required = count( array_filter( $open, array( StoreConditions::class, 'shows_required' ) ) );
if ( $required > 0 ) {
@@ -452,7 +454,11 @@ class AgenticCommerceSettingsPage extends \WC_Settings_Page {
return array(
'title' => __( 'Setup checklist', 'woocommerce' ),
- 'badge' => array() === $open ? null : array(
+ // As in the design: the steps left, or All steps done in green once none are.
+ 'badge' => array() === $open ? array(
+ 'intent' => 'stable',
+ 'text' => __( 'All steps done', 'woocommerce' ),
+ ) : array(
'intent' => 'none',
/* translators: %d: number of setup steps left. */
'text' => sprintf( _n( '%d step left', '%d steps left', count( $open ), 'woocommerce' ), count( $open ) ),
@@ -465,38 +471,4 @@ class AgenticCommerceSettingsPage extends \WC_Settings_Page {
'hide_done' => __( 'Hide completed steps', 'woocommerce' ),
);
}
-
- /**
- * A setup step's button, as in the design: where it goes, or Review. Policy steps repeat the same
- * button, so screen readers also hear which policy it is for.
- *
- * @param string $id Store condition ID.
- * @param string $link The link text check_action() gives when the URL alone doesn't say it, such as Change permalinks.
- * @return array{0:string,1:string} The button text, and the policy it is for, or ''.
- */
- private static function step_button( string $id, string $link ): array {
- // Policy buttons repeat, so each one's accessible name says which page it is for.
- $policies = array(
- 'privacy_page' => array( __( 'Choose a privacy policy page', 'woocommerce' ), __( 'Edit your privacy policy page', 'woocommerce' ) ),
- 'terms_page' => array( __( 'Choose a terms and conditions page', 'woocommerce' ), __( 'Edit your terms and conditions page', 'woocommerce' ) ),
- 'refund_returns_page' => array( __( 'Choose a refund and returns policy page', 'woocommerce' ), __( 'Edit your refund and returns policy page', 'woocommerce' ) ),
- 'shipping_policy_page' => array( __( 'Choose a shipping policy page', 'woocommerce' ), __( 'Edit your shipping policy page', 'woocommerce' ) ),
- );
- if ( isset( $policies[ $id ] ) ) {
- // A policy page that is still a draft opens its editor.
- return '' !== $link ? array( __( 'Edit page', 'woocommerce' ), $policies[ $id ][1] ) : array( __( 'Choose page', 'woocommerce' ), $policies[ $id ][0] );
- }
- $labels = array(
- 'https' => __( 'View Site Health', 'woocommerce' ),
- 'launched' => __( 'Change store visibility', 'woocommerce' ),
- 'guest_checkout' => __( 'View account settings', 'woocommerce' ),
- 'payment_method' => __( 'View payment settings', 'woocommerce' ),
- 'order_emails' => __( 'View email settings', 'woocommerce' ),
- 'search_visible' => __( 'Change Reading settings', 'woocommerce' ),
- // Change permalinks, and only when permalinks are one of the fixes.
- 'ucp_discovery' => $link,
- );
- $label = $labels[ $id ] ?? '';
- return array( '' !== $label ? $label : __( 'Review', 'woocommerce' ), '' );
- }
}
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/README.md b/plugins/woocommerce/src/Internal/AgentReadiness/README.md
index adf8d8da64b..131a6410259 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/README.md
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/README.md
@@ -209,9 +209,9 @@ WooCommerce > Settings > AI tools (`AgenticCommerceSettings`, `AgenticCommerceSe
AI shopping has one card per part:
-- The UCP switch, first, with Learn how it works. It saves on its own through `POST wc/v3/agent-readiness/ucp` (`{ "enabled": true }`). A failing required check keeps it from being turned on, and that POST answers 409; turning it off still works. While it is on and the required checks pass it says "AI assistants can now find and shop your store." The page reloads after it changes, unless a policy field has unsaved changes; then it asks to save them. In coming soon mode the card has a warning notice that agents can't shop the store yet, with Change store visibility.
+- The UCP switch, first, with Learn how it works. It saves on its own through `POST wc/v3/agent-readiness/ucp` (`{ "enabled": true }`). A failing required check keeps it from being turned on, and that POST answers 409; turning it off still works. After it changes, a snackbar says "AI assistants can now shop your store." or "AI assistants can no longer shop your store." The page reloads after it changes and shows the snackbar, unless a policy field has unsaved changes; then the snackbar shows at once and it asks to save them. In coming soon mode the card has a warning notice that agents can't shop the store yet, with Change store visibility.
- Product visibility: Visible, Hidden and Not supported, from the stored report (`products`, `hidden_from_catalog`, `unsupported_types`). Each links to the Products list filtered to those products (`ProductScan::count_query()`, the query the scan counts with). Hidden and Not supported have an info button that opens a popover saying what they mean.
-- Setup checklist: a badge with how many steps are left, then the store conditions from `StoreConditions`, the same list the readiness report shows. Open conditions are one list, failing `required` ones first (coming soon mode, HTTPS and the UCP address), marked Required; failing `recommended` ones, such as a missing privacy, terms, refund and returns, or shipping policy page (policy pages are not required by the UCP spec), follow. The card says how many required steps are left to fix, or how many steps are left when none is required. Each step says why it matters and links to where to fix it; a chosen policy page that isn't published links to its editor, and a store page chosen as one asks for another page. Each open step's button says where it goes (View Site Health, Choose page, Edit page and so on). Passing conditions fold behind "Show N completed steps", with the same title and why line.
+- Setup checklist: a badge with how many steps are left, then the store conditions from `StoreConditions`, the same list the readiness report shows. Open conditions are one list, failing `required` ones first (coming soon mode, HTTPS and the UCP address), marked Required; failing `recommended` ones, such as a missing privacy, terms, refund and returns, or shipping policy page (policy pages are not required by the UCP spec), follow. The card says how many required steps are left to fix, or how many steps are left when none is required. Each step says why it matters and links to where to fix it; a chosen policy page that isn't published links to its editor, and a store page chosen as one asks for another page. Each open step's button says where it goes (View Site Health, Choose page, Edit page and so on). Passing conditions fold behind "Show N completed steps", with the same title and why line. Both lists, and the setup steps in Fix first, go by importance (`ReadinessCheckPage::SETUP_ORDER`): what blocks AI shopping (live, HTTPS, readable permalinks), then payments, the privacy, terms and refund pages, search engine indexing and order emails, then guest checkout and the shipping policy page.
- Store policy pages. Refund and returns, privacy and terms are the existing options, so they stay in sync with Advanced > Page setup and Settings > Privacy; shipping policy, FAQ and warranty are new. They are for the policy links a UCP checkout can carry (`links`); the UCP endpoints don't send them yet. The dropdowns list published pages other than the cart, checkout, shop and My account pages, and saving leaves a stored page in place even when it's a draft or one of those store pages, which then fails its check. A link from the checklist opens the page on its field, focused.
- The connection URL AI assistants start from (`/.well-known/ucp`), read only, with Copy and a link to test it in UCP Playground.
@@ -219,7 +219,7 @@ Sales readiness opens with when the last check ran and Check again ("Check your
The product checks, under "Listings in AI shopping apps", show how many products each channel can list ("2 of 15 can be listed"), then each failing product check, titled with what to do and its count ("Add a brand to 13 products"), why it matters, and "View N products", which opens the Products list filtered to them. With up to three failing products the title names them ("Add a brand to Blue hoodie and Red cap") when their failures are stored; one product without them is "a product", and more than three are counted. The copy is in `ReadinessCopy`. Product image alt text isn't listed there, since the `images_have_alt` store check covers it.
-Fix first, a card of its own, lists the required setup steps that fail, then the top three other issues. Required setup steps include the ones shown as Required (`StoreConditions::SHOWN_REQUIRED`, or `store_checks` in the rules file): `search_visible`, `payment_method`, `order_emails`, `privacy_page`, `terms_page` and `refund_returns_page`. Guest checkout is optional. Of the scanned checks, a failing `ucp_profile` or `ucp_checkout` is Required with UCP on, and so is one that keeps AI assistants off the store's pages, except `pages_public`: a store whose pages all need a login, such as a members-only store, chose that and can still be ready for AI assistants that sign in. It is Recommended: it shows in Store access without a badge and in Fix first under Needed to list products, and doesn't count toward the required steps or keep AI shopping from being turned on. A failing `ucp_endpoints_live` shows a Warning instead, with the status and content type catalog search last answered, since it can fail now and then with nothing changed on the store. Issues are ranked by what they stop, then by sales: store checks that block `listing` (such as structured data) and product checks that keep products off a channel (`not_listable`), then product checks that only make products harder to find. Within each, the larger share of sales on the affected products comes first, then the larger product count, then page order. Without sales to compare, a product check's count is multiplied by the AI apps it affects, so 3 products kept out of 3 apps come before 5 products kept out of 1. Store checks with no sales link, such as a missing meta description, stay out of Fix first. `ProductSales` reads each product's net sales over the last 90 days from the Analytics lookup tables (`wc_order_product_lookup` joined with `wc_order_stats`), with the order statuses Analytics excludes left out and variations counted toward their parent and on their own. The scan adds up the sales of each check's failing products. A check a variable product fails through some of its variations (a missing price or GTIN, a missing variation image, or an option set to "any") adds only those variations' sales. An invalid GTIN, a GTIN shared with another product, and an image under 500 pixels still count the whole product's sales, which only changes the rank. The report stores each check's `sales_share` (0 to 1) and `sales` (`days`, `orders`, `imported`). While Analytics is off, `sales` is null. With fewer than `ProductSales::MIN_ORDERS` (20) orders in the period, too few to rank by, shares are null. They are null too while a store with at least 20 orders has under 90% of them in Analytics (`imported` false), as when past orders were never imported. Orders in several currencies are summed without conversion, as Analytics does. In both cases Fix first ranks by product count and AI apps, and says why. It says to start with the fixes that affect the most sales, over the period the figures cover, only when an issue on the card sold something; otherwise it says it ranks by product count. A share is rounded to 4 places and any sales keep at least 0.0001, so small sales never read as "No sales". A share is not shown once a check's count changes after the scan, since it was measured on the products failing then, but Fix first still ranks the check by it (`ranked_share`), so fixing one product doesn't move the issue down. Under headings for what each group stops (Required for AI shopping, Needed to list products, Helps shoppers find products), a product issue is badged by its share of sales ("38% of sales"); its line starts with the share, the first saying over which period ("38% of your sales in the last 90 days."); products that sold nothing in the period say "No sales" instead of 0%.
+Fix first, a card of its own, lists the required setup steps that fail, then the top three other issues. Required setup steps include the ones shown as Required (`StoreConditions::SHOWN_REQUIRED`, or `store_checks` in the rules file): `search_visible`, `payment_method`, `order_emails`, `privacy_page`, `terms_page` and `refund_returns_page`. Guest checkout is optional. Of the scanned checks, a failing `ucp_profile` or `ucp_checkout` is Required with UCP on, and so is one that keeps AI assistants off the store's pages, except `pages_public`: a store whose pages all need a login, such as a members-only store, chose that and can still be ready for AI assistants that sign in. It is Recommended: it shows in Store access without a badge and in Fix first under Needed to list products, and doesn't count toward the required steps or keep AI shopping from being turned on. A failing `ucp_endpoints_live` has no badge, like any failing check that isn't Required, and stays out of Fix first, since it can fail now and then with nothing changed on the store. A question card's badge counts its issues, says All passed, or, when nothing failed but a check couldn't run, says Couldn't check (the row says why); before the first check it says Not checked yet. Issues are ranked by what they stop, then by sales: store checks that block `listing` (such as structured data) and product checks that keep products off a channel (`not_listable`), then product checks that only make products harder to find. Within each, the larger share of sales on the affected products comes first, then the larger product count, then page order. Without sales to compare, a product check's count is multiplied by the AI apps it affects, so 3 products kept out of 3 apps come before 5 products kept out of 1. Store checks with no sales link, such as a missing meta description, stay out of Fix first. `ProductSales` reads each product's net sales over the last 90 days from the Analytics lookup tables (`wc_order_product_lookup` joined with `wc_order_stats`), with the order statuses Analytics excludes left out and variations counted toward their parent and on their own. The scan adds up the sales of each check's failing products. A check a variable product fails through some of its variations (a missing price or GTIN, a missing variation image, or an option set to "any") adds only those variations' sales. An invalid GTIN, a GTIN shared with another product, and an image under 500 pixels still count the whole product's sales, which only changes the rank. The report stores each check's `sales_share` (0 to 1) and `sales` (`days`, `orders`, `imported`). While Analytics is off, `sales` is null. With fewer than `ProductSales::MIN_ORDERS` (20) orders in the period, too few to rank by, shares are null. They are null too while a store with at least 20 orders has under 90% of them in Analytics (`imported` false), as when past orders were never imported. Orders in several currencies are summed without conversion, as Analytics does. In both cases Fix first ranks by product count and AI apps, and says why. It says to start with the fixes that affect the most sales, over the period the figures cover, only when an issue on the card sold something; otherwise it says it ranks by product count. A share is rounded to 4 places and any sales keep at least 0.0001, so small sales never read as "No sales". A share is not shown once a check's count changes after the scan, since it was measured on the products failing then, but Fix first still ranks the check by it (`ranked_share`), so fixing one product doesn't move the issue down. Under headings for what each group stops (Required for AI shopping, Needed to list products, Helps shoppers find products), a product issue is badged by its share of sales ("38% of sales"); its line starts with the share, the first saying over which period ("38% of your sales in the last 90 days."); products that sold nothing in the period say "No sales" instead of 0%.
Tracks event: `agentic_commerce_ucp_toggled` (`enabled`), sent only when the store allows tracking.
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCheckPage.php b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCheckPage.php
index 5052325853b..dcf470ddcaa 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCheckPage.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCheckPage.php
@@ -27,6 +27,12 @@ class ReadinessCheckPage implements RegisterHooksInterface {
public const PATH = '/sales-readiness';
+ /**
+ * Setup steps by importance: what blocks AI shopping (live, HTTPS, readable permalinks), what
+ * stops orders or is asked for by AI shopping channels, then the optional steps.
+ */
+ private const SETUP_ORDER = array( 'launched', 'https', 'ucp_discovery', 'payment_method', 'privacy_page', 'terms_page', 'refund_returns_page', 'search_visible', 'order_emails', 'guest_checkout', 'shipping_policy_page' );
+
/**
* The admin_menu priority: between WooCommerce's Reports (20) and Settings (50).
*/
@@ -37,6 +43,14 @@ class ReadinessCheckPage implements RegisterHooksInterface {
*/
private const HIDDEN_PRODUCT_CHECKS = array( 'image_alt_text' );
+ /**
+ * Product ids already loaded while building one view, by check id and limit. A check that appears
+ * in Fix first and on its card is queried once. view() clears this, so the next call reads current products.
+ *
+ * @var array<string, array<int, int[]>>
+ */
+ private static $failing_ids = array();
+
/**
* Whether Sales readiness hides this product check (it still appears in the support download).
*
@@ -58,12 +72,6 @@ class ReadinessCheckPage implements RegisterHooksInterface {
*/
private const REQUIRED_SCANNED = array( 'ucp_profile', 'ucp_checkout' );
- /**
- * Scanned checks shown with a Warning instead of as Required when they fail: catalog search can fail
- * now and then with nothing changed on the store, usually because of something in front of it.
- */
- private const WARNING_SCANNED = array( 'ucp_endpoints_live' );
-
/**
* Scanned checks that keep products from being listed but aren't Required: a store whose pages all
* need a login, such as a members-only store, chose that, and can still be ready for AI assistants that sign in.
@@ -107,7 +115,6 @@ class ReadinessCheckPage implements RegisterHooksInterface {
'pass' => 'stable',
'off' => 'none',
'fix' => 'low',
- 'warn' => 'medium',
);
/**
@@ -203,14 +210,14 @@ class ReadinessCheckPage implements RegisterHooksInterface {
}
/**
- * The AI shopping badge: Needs attention while a required step fails, even with UCP off,
- * otherwise Active or Off as UCP is.
+ * The AI shopping badge: Needs attention while a step shown as Required is open, even with UCP off,
+ * otherwise Active or Off as UCP is. It counts the same steps as the card's Continue setup button.
*
- * @param array<int, array{id:string,ok:bool,level:string}> $checks Store conditions.
+ * @param array<int, array{id:string,ok:bool,blocks:string,level:string,name:string,label:string,why:string,fix:string,fix_url:string}> $checks Store conditions.
* @return array{0:string,1:string} Badge class and text.
*/
public function shopping_badge( array $checks ): array {
- if ( array() !== $this->store_conditions->failing_required( $checks ) ) {
+ if ( array() !== array_filter( self::open_steps( $checks ), array( StoreConditions::class, 'shows_required' ) ) ) {
return array( 'check', __( 'Needs attention', 'woocommerce' ) );
}
return UcpUtils::is_enabled() ? array( 'pass', __( 'Active', 'woocommerce' ) ) : array( 'off', __( 'Off', 'woocommerce' ) );
@@ -223,24 +230,53 @@ class ReadinessCheckPage implements RegisterHooksInterface {
* @return array<int, array{id:string,ok:bool,blocks:string,level:string,name:string,label:string,why:string,fix:string,fix_url:string}>
*/
public static function open_steps( array $checks ): array {
- $open = self::setup_order( array_filter( $checks, static fn( array $check ): bool => 'ucp_on' !== $check['id'] && ! $check['ok'] ) );
+ return self::required_first( self::setup_order( array_filter( $checks, static fn( array $check ): bool => 'ucp_on' !== $check['id'] && ! $check['ok'] ) ) );
+ }
+
+ /**
+ * The setup steps already done, in the same order as the open ones.
+ *
+ * @param array<int, array{id:string,ok:bool,blocks:string,level:string,name:string,label:string,why:string,fix:string,fix_url:string}> $checks Store conditions.
+ * @return array<int, array{id:string,ok:bool,blocks:string,level:string,name:string,label:string,why:string,fix:string,fix_url:string}>
+ */
+ public static function done_steps( array $checks ): array {
+ return self::required_first( self::setup_order( array_filter( $checks, static fn( array $check ): bool => 'ucp_on' !== $check['id'] && $check['ok'] ) ) );
+ }
+
+ /**
+ * Required steps first, keeping setup order inside each group. A step the rules file marks
+ * Required moves ahead of the Optional ones, open or done.
+ *
+ * @template T of array{id:string,level:string}
+ * @param array<int|string, T> $checks Store conditions, already in setup order.
+ * @return array<int, T>
+ */
+ private static function required_first( array $checks ): array {
$required = array( StoreConditions::class, 'shows_required' );
- return array_merge( array_values( array_filter( $open, $required ) ), array_values( array_filter( $open, static fn( array $check ): bool => ! $required( $check ) ) ) );
+ return array_merge( array_values( array_filter( $checks, $required ) ), array_values( array_filter( $checks, static fn( array $check ): bool => ! $required( $check ) ) ) );
}
/**
- * Setup steps in the order the pages list them: HTTPS first, then as StoreConditions lists them,
- * which is also the order the report and the ability keep.
+ * Setup steps by importance: the ones that block AI shopping, then the Required ones, then the
+ * Optional ones (SETUP_ORDER). A step not in that list keeps its place after them.
*
* @template T of array{id:string}
* @param array<int|string, T> $checks Store conditions.
* @return array<int, T>
*/
private static function setup_order( array $checks ): array {
- return array_merge(
- array_values( array_filter( $checks, static fn( array $check ): bool => 'https' === $check['id'] ) ),
- array_values( array_filter( $checks, static fn( array $check ): bool => 'https' !== $check['id'] ) )
- );
+ $rank = array_flip( self::SETUP_ORDER );
+ $ranked = array();
+ $rest = array();
+ foreach ( $checks as $check ) {
+ if ( isset( $rank[ $check['id'] ] ) ) {
+ $ranked[ $rank[ $check['id'] ] ] = $check;
+ } else {
+ $rest[] = $check;
+ }
+ }
+ ksort( $ranked );
+ return array_merge( array_values( $ranked ), $rest );
}
/**
@@ -251,6 +287,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
* @return array<string, mixed>
*/
public function view(): array {
+ self::$failing_ids = array();
// Pending on either side of the report read: a scan that finishes during the read must not
// pair an old report with pending false, and a scan queued during the read must not be hidden.
$pending = $this->scheduled_scan->is_pending();
@@ -264,7 +301,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
if ( $stalled ) {
$message = __( 'Checks can’t start because scheduled actions aren’t running on your site. Your hosting provider can usually turn them back on.', 'woocommerce' );
} elseif ( $pending ) {
- $message = __( 'Checking your store.', 'woocommerce' );
+ $message = __( 'Checking your store', 'woocommerce' );
}
$truncated = null;
if ( null !== $report && ! empty( $report['truncated'] ) ) {
@@ -280,7 +317,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
'description' => __( 'Check how well AI assistants can find and shop your store, and what to improve first.', 'woocommerce' ),
'last_checked' => self::last_checked( $report ),
'checked_note' => $truncated,
- 'intro' => null === $report ? __( 'Run a check to see what AI assistants get when they visit your store and read your products.', 'woocommerce' ) : null,
+ 'checked' => null !== $report,
'run' => array(
'label' => null === $report ? __( 'Check your store', 'woocommerce' ) : __( 'Check again', 'woocommerce' ),
'pending' => $pending,
@@ -293,6 +330,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
),
// The support line's link: WordPress.com support on WordPress.com, else the one in WooCommerce > Home > Help.
'support_url' => UcpDiscovery::is_wordpress_com() ? 'https://wordpress.com/help/contact' : 'https://woocommerce.com/my-account/create-a-ticket/?utm_medium=product',
+ 'coming_soon' => self::coming_soon_notice( $checks, $report ),
'fix_first' => null === $report ? null : $this->fix_first( $visible, $report ),
// Setup steps live in the Setup checklist and, while one blocks sales, in Fix first; the cards hold what the scan read.
'sections' => null === $report ? array() : $this->sections( array_values( array_filter( $visible, static fn( array $check ): bool => ! self::is_setup_step( $check ) ) ), $launched, $report ),
@@ -390,34 +428,80 @@ class ReadinessCheckPage implements RegisterHooksInterface {
return $product instanceof \WC_Product ? wp_strip_all_tags( html_entity_decode( $product->get_name(), ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ) : '';
}
+ /**
+ * The link on the product name in "On the Blue hoodie page, …", to that page. `at` is where the name
+ * starts in the line, in UTF-16 code units, the index the page uses to slice the text. A name that
+ * also appears earlier ("the") is still the one linked. Null when the line names no product.
+ *
+ * @param array $check Store check.
+ * @param int $product_id Product ID from the report.
+ * @param string $product The product's name, or ''.
+ * @param string $found The found line.
+ * @return array{href:string,text:string,at:int}|null
+ */
+ private static function product_link( array $check, int $product_id, string $product, string $found ): ?array {
+ $href = '' !== $product ? get_permalink( $product_id ) : false;
+ if ( ! is_string( $href ) || '' === $href ) {
+ return null;
+ }
+ // The same line with a placeholder for the name shows where the name goes, in any language.
+ $marker = "\u{E000}";
+ $marked = ReadinessCopy::store_check( $check['id'], (string) ( $check['source'] ?? '' ), $marker, (string) ( $check['seen_at'] ?? '' ), true );
+ $at = null === $marked ? false : strpos( $marked['found'], $marker );
+ if ( false === $at || substr( $found, $at, strlen( $product ) ) !== $product ) {
+ return null;
+ }
+ return array(
+ 'href' => $href,
+ 'text' => $product,
+ 'at' => self::utf16_units( substr( $found, 0, $at ) ),
+ );
+ }
+
+ /**
+ * How many UTF-16 code units $text has. The page slices with JavaScript, which counts in those
+ * units, so an emoji before the product name is two, not one.
+ *
+ * @param string $text Text before the product name.
+ */
+ private static function utf16_units( string $text ): int {
+ $utf16 = mb_convert_encoding( $text, 'UTF-16LE', 'UTF-8' );
+ return is_string( $utf16 ) ? intdiv( strlen( $utf16 ), 2 ) : 0;
+ }
+
/**
* What a failing store check says: what to do, why it matters and what was found, the fix line,
* and where to fix it. A setup step is worded as in Status; a scanned check takes its copy from
* ReadinessCopy, or from the report for a check that has none there.
*
* @param array{id:string,name:string,label?:string,why:string,fix?:string,fix_url:string,conflict?:bool,source?:string,product?:int,seen_at?:string} $check Store check.
- * @return array{title:string,text:string,fix:string,url:string,link?:string,tool?:array{href:string,text:string}|null}
+ * @return array{title:string,text:string,fix:string,url:string,link?:string,sr?:string,tool?:array{href:string,text:string,at?:int}|null}
*/
private static function failing_copy( array $check ): array {
if ( self::is_setup_step( $check ) ) {
$action = self::check_action( $check );
+ // Policy pages share one button text, Edit page or Choose page, as in the Setup checklist, so the
+ // button column stays narrow; screen readers also hear which policy it is for.
+ $button = self::step_button( $check['id'], $action[3] );
return array(
'title' => $action[0],
'text' => $action[1],
'fix' => $action[4],
'url' => $action[2],
- 'link' => $action[3],
+ 'link' => '' !== $button[1] ? $button[0] : $action[3],
+ 'sr' => $button[1],
);
}
$product_id = (int) ( $check['product'] ?? 0 );
- $copy = ReadinessCopy::store_check( $check['id'], (string) ( $check['source'] ?? '' ), self::product_name( $product_id ), (string) ( $check['seen_at'] ?? '' ), $product_id > 0 );
+ $product = self::product_name( $product_id );
+ $copy = ReadinessCopy::store_check( $check['id'], (string) ( $check['source'] ?? '' ), $product, (string) ( $check['seen_at'] ?? '' ), $product_id > 0 );
if ( null !== $copy ) {
return array(
'title' => $copy['action'],
'text' => $copy['found'],
'fix' => ReadinessCopy::llms_txt_source( (string) ( $check['source'] ?? '' ) )['fix'] ?? $copy['fix'],
'url' => '' !== $copy['url'] ? $copy['url'] : $check['fix_url'],
- 'tool' => $copy['found_link'],
+ 'tool' => null === $copy['found_link'] ? self::product_link( $check, $product_id, $product, $copy['found'] ) : $copy['found_link'],
);
}
return array(
@@ -596,7 +680,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
return array(
'id' => $id,
'title' => $title,
- 'badge' => self::badge_data( array( 'off', $unreadable ? __( 'Not checked', 'woocommerce' ) : __( 'No products', 'woocommerce' ) ) ),
+ 'badge' => self::badge_data( self::cant_check_badge() ),
'note' => null,
'channels' => array(),
'rows' => array(),
@@ -619,6 +703,34 @@ class ReadinessCheckPage implements RegisterHooksInterface {
);
}
+ /**
+ * The notice above Fix first while the store is in coming soon mode and the results shown are from
+ * a check that ran while it was live. A check that runs in coming soon mode replaces them, so then
+ * the cards say why the checks didn't run instead.
+ *
+ * @param array<int, array<string, mixed>> $checks Store conditions now.
+ * @param array<string, mixed>|null $report Stored report.
+ * @return array{text:string,link:array{href:string,text:string}}|null
+ */
+ private static function coming_soon_notice( array $checks, ?array $report ): ?array {
+ $launched = array_column( $checks, null, 'id' )['launched'] ?? null;
+ if ( null === $launched || false !== $launched['ok'] || null === $report ) {
+ return null;
+ }
+ $was_live = array_column( is_array( $report['store_checks'] ?? null ) ? $report['store_checks'] : array(), 'ok', 'id' )['launched'] ?? null;
+ if ( true !== $was_live ) {
+ return null;
+ }
+ return array(
+ 'text' => __( 'Your store is in coming soon mode, so AI assistants can’t find your products yet. These results are from when your store was live.', 'woocommerce' ),
+ 'link' => array(
+ 'href' => (string) $launched['fix_url'],
+ // The same button as the AI shopping notice, from the content review.
+ 'text' => __( 'Change store visibility', 'woocommerce' ),
+ ),
+ );
+ }
+
/**
* Whether a scan ran none of these checks, and none is still waiting for one: the store showed
* its coming soon page, or its host stopped it from opening its own pages.
@@ -671,15 +783,15 @@ class ReadinessCheckPage implements RegisterHooksInterface {
/**
* One check row for the React views.
*
- * @param string $id The check's id.
- * @param string $state open, required, unknown or pass.
- * @param string $title Title: what to do while it fails.
- * @param string $text Why it matters, and what was found while it fails.
- * @param string $fix What to do, or '' when the title says it.
- * @param array{href:string,text:string}|null $link Where to fix it, or the products it affects.
- * @param array{0:string,1:string}|null $badge Badge class and text: Required.
- * @param array{href:string,text:string}|null $seen_at The page a conflict was seen on.
- * @param array{href:string,text:string}|null $text_link A name in the text to link, such as a tool to test with.
+ * @param string $id The check's id.
+ * @param string $state open, required, unknown or pass.
+ * @param string $title Title: what to do while it fails.
+ * @param string $text Why it matters, and what was found while it fails.
+ * @param string $fix What to do, or '' when the title says it.
+ * @param array{href:string,text:string,sr?:string}|null $link Where to fix it, or the products it affects. `sr` is what screen readers hear.
+ * @param array{0:string,1:string}|null $badge Badge class and text: Required.
+ * @param array{href:string,text:string}|null $seen_at The page a conflict was seen on.
+ * @param array{href:string,text:string,at?:int}|null $text_link A name in the text to link, such as a tool to test with, and where it starts.
* @return array<string, mixed>
*/
private static function row( string $id, string $state, string $title, string $text, string $fix = '', ?array $link = null, ?array $badge = null, ?array $seen_at = null, ?array $text_link = null ): array {
@@ -703,7 +815,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
*
* @param array<int, array{id:string,ok:bool|null,blocks:string,group?:string,level:string,name:string,label?:string,why:string,fix:string,fix_url:string,conflict?:bool,pending?:bool,seen_at?:string}> $checks Store checks shown on the page.
* @param array<string, mixed> $report Stored report.
- * @return array<int, array{id:string,tier:int,title:string,why:string,link:array{href:string,text:string}|null,share:float|null,store:bool,rank:float,count:int}>
+ * @return array<int, array{id:string,tier:int,title:string,why:string,link:array{href:string,text:string,sr?:string}|null,share:float|null,store:bool,rank:float,count:int}>
*/
private function fix_first_items( array $checks, array $report ): array {
$required = array();
@@ -722,7 +834,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
'tier' => $is_required ? 0 : 2,
'title' => $copy['title'],
'why' => $copy['text'],
- 'link' => self::fix_link( $copy['url'], $copy['link'] ?? '' ),
+ 'link' => self::fix_link( $copy['url'], $copy['link'] ?? '', $copy['sr'] ?? '' ),
'share' => null,
'store' => true,
// A store-wide issue affects every product, so it ranks as all sales.
@@ -800,15 +912,34 @@ class ReadinessCheckPage implements RegisterHooksInterface {
return array(
'title' => __( 'Fix first', 'woocommerce' ),
'ranking' => self::ranking_text( $report, $items ),
- // With Analytics off, where to turn it on: a report with a null `sales` key was read without it.
- 'link' => array_key_exists( 'sales', $report ) && null === $report['sales'] ? array(
- 'href' => admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=features' ),
- 'text' => __( 'Turn on Analytics to see which fixes affect the most sales.', 'woocommerce' ),
- ) : null,
+ 'link' => self::ranking_link( $report ),
'items' => $list,
);
}
+ /**
+ * Where to go so Fix first can rank by sales: turn on Analytics (a report with a null `sales` key was read
+ * without it), or import past orders in Analytics settings.
+ *
+ * @param array<string, mixed> $report Stored report.
+ * @return array{href:string,text:string}|null
+ */
+ private static function ranking_link( array $report ): ?array {
+ if ( array_key_exists( 'sales', $report ) && null === $report['sales'] ) {
+ return array(
+ 'href' => admin_url( 'admin.php?page=wc-settings&tab=advanced§ion=features' ),
+ 'text' => __( 'Turn on Analytics to see which fixes affect the most sales.', 'woocommerce' ),
+ );
+ }
+ if ( is_array( $report['sales'] ?? null ) && false === ( $report['sales']['imported'] ?? true ) ) {
+ return array(
+ 'href' => admin_url( 'admin.php?page=wc-admin&path=/analytics/settings' ),
+ 'text' => __( 'Import your past orders in Analytics settings', 'woocommerce' ),
+ );
+ }
+ return null;
+ }
+
/**
* How Fix first is ranked, and what the sales shares compare. Sales are named only when an issue
* on the card has sales to compare.
@@ -826,7 +957,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
return __( 'Start with the fixes that affect the most products.', 'woocommerce' );
}
if ( false === ( $sales['imported'] ?? true ) ) {
- return __( 'Analytics hasn\'t imported all your past orders yet, so issues are ranked by how many products and AI apps they affect. Import them in Analytics > Settings.', 'woocommerce' );
+ return __( 'Analytics hasn\'t imported all your past orders yet, so issues are ranked by how many products and AI apps they affect.', 'woocommerce' );
}
$orders = (int) ( $sales['orders'] ?? 0 );
$days = (int) ( $sales['days'] ?? 0 );
@@ -860,7 +991,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
/**
* "View N products", linked to the Products list filtered to them when each product's failures
- * are stored; "N products" with no link otherwise.
+ * are stored; "N products" with no link otherwise. One product opens its edit page instead.
*
* @param int $count Number of products.
* @param string $value Stored failure value.
@@ -875,8 +1006,10 @@ class ReadinessCheckPage implements RegisterHooksInterface {
'text' => sprintf( _n( '%s product', '%s products', $count, 'woocommerce' ), number_format_i18n( $count ) ),
);
}
+ $ids = 1 === $count ? self::failing_product_ids( $value, 2 ) : array();
+ $edit = 1 === count( $ids ) ? (string) get_edit_post_link( $ids[0], 'raw' ) : '';
return array(
- 'href' => ProductsList::url( $value ),
+ 'href' => '' !== $edit ? $edit : ProductsList::url( $value ),
/* translators: %s: number of products. */
'text' => 1 === $count ? __( 'View product', 'woocommerce' ) : sprintf( _n( 'View %s product', 'View %s products', $count, 'woocommerce' ), number_format_i18n( $count ) ),
);
@@ -918,21 +1051,42 @@ class ReadinessCheckPage implements RegisterHooksInterface {
* @return string[]
*/
private static function failing_product_names( string $check_id ): array {
- $posts = get_posts(
- array(
- 'post_type' => 'product',
- 'post_status' => 'any',
- 'posts_per_page' => ReadinessCopy::NAMED_MAX + 1,
- 'no_found_rows' => true,
- 'suppress_filters' => true,
- 'meta_key' => ProductFailures::META_KEY, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
- 'meta_value' => $check_id, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
- )
- );
return array_map(
- static fn( \WP_Post $post ): string => html_entity_decode( wp_strip_all_tags( get_the_title( $post ) ), ENT_QUOTES, 'UTF-8' ),
- $posts
+ static fn( int $id ): string => html_entity_decode( wp_strip_all_tags( get_the_title( $id ) ), ENT_QUOTES, 'UTF-8' ),
+ self::failing_product_ids( $check_id, ReadinessCopy::NAMED_MAX + 1 )
+ );
+ }
+
+ /**
+ * Ids of up to $limit products that fail a check, from their stored failures.
+ *
+ * @param string $check_id Check id.
+ * @param int $limit Most ids to return.
+ * @return int[]
+ */
+ private static function failing_product_ids( string $check_id, int $limit ): array {
+ foreach ( self::$failing_ids[ $check_id ] ?? array() as $cached_limit => $ids ) {
+ if ( $cached_limit >= $limit ) {
+ return array_slice( $ids, 0, $limit );
+ }
+ }
+ $ids = array_map(
+ 'intval',
+ get_posts(
+ array(
+ 'post_type' => 'product',
+ 'post_status' => 'any',
+ 'posts_per_page' => $limit,
+ 'fields' => 'ids',
+ 'no_found_rows' => true,
+ 'suppress_filters' => true,
+ 'meta_key' => ProductFailures::META_KEY, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
+ 'meta_value' => $check_id, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
+ )
+ )
);
+ self::$failing_ids[ $check_id ][ $limit ] = $ids;
+ return $ids;
}
/**
@@ -1007,23 +1161,33 @@ class ReadinessCheckPage implements RegisterHooksInterface {
}
/**
- * The badge on a question: how many issues, or that everything passed. A check that
- * couldn't run isn't an issue.
+ * The badge on a question: how many issues, that everything passed, or, when nothing failed but
+ * a check couldn't run, Couldn't check (its row says why). Before the first check, Not checked yet.
*
- * @param array<int, array{ok:bool|null}> $checks The question's checks.
+ * @param array<int, array{ok:bool|null}> $checks The question's checks.
+ * @param bool $checked Whether a check has run.
* @return array{0:string,1:string} Badge class and text.
*/
- private static function group_badge( array $checks ): array {
+ private static function group_badge( array $checks, bool $checked = true ): array {
$issues = count( array_filter( $checks, static fn( array $check ): bool => false === $check['ok'] ) );
if ( $issues > 0 ) {
/* translators: %d: number of issues. */
return array( 'check', sprintf( _n( '%d issue', '%d issues', $issues, 'woocommerce' ), $issues ) );
}
$passed = count( array_filter( $checks, static fn( array $check ): bool => true === $check['ok'] ) );
- if ( 0 === $passed ) {
- return array( 'off', __( 'Not checked yet', 'woocommerce' ) );
+ if ( $passed > 0 && count( $checks ) === $passed ) {
+ return array( 'info', __( 'All passed', 'woocommerce' ) );
}
- return count( $checks ) === $passed ? array( 'info', __( 'All passed', 'woocommerce' ) ) : array( 'off', __( 'No issues', 'woocommerce' ) );
+ return $checked ? self::cant_check_badge() : array( 'off', __( 'Not checked yet', 'woocommerce' ) );
+ }
+
+ /**
+ * The Couldn't check badge, on a question where nothing failed but a check couldn't run.
+ *
+ * @return array{0:string,1:string} Badge class and text.
+ */
+ private static function cant_check_badge(): array {
+ return array( 'off', __( 'Couldn’t check', 'woocommerce' ) );
}
/**
@@ -1064,9 +1228,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
'text' => (string) $check['seen_at'],
)
: null;
- $warning = ! $required && in_array( $check['id'], self::WARNING_SCANNED, true );
- $badge = $required ? self::required_badge() : ( $warning ? array( 'warn', __( 'Warning', 'woocommerce' ) ) : null );
- $rows[] = self::row( $check['id'], $required ? 'required' : 'open', $failing['title'], $failing['text'], $failing['fix'], self::fix_link( $failing['url'], $failing['link'] ?? '' ), $badge, $seen_at, $failing['tool'] ?? null );
+ $rows[] = self::row( $check['id'], $required ? 'required' : 'open', $failing['title'], $failing['text'], $failing['fix'], self::fix_link( $failing['url'], $failing['link'] ?? '', $failing['sr'] ?? '' ), $required ? self::required_badge() : null, $seen_at, $failing['tool'] ?? null );
}
return $rows;
}
@@ -1076,18 +1238,23 @@ class ReadinessCheckPage implements RegisterHooksInterface {
*
* @param string $url Fix URL.
* @param string $text Link text, or '' to name where the URL goes.
- * @return array{href:string,text:string}|null
+ * @param string $sr What screen readers hear in place of the text, or ''.
+ * @return array{href:string,text:string,sr?:string}|null
*/
- private static function fix_link( string $url, string $text = '' ): ?array {
+ private static function fix_link( string $url, string $text = '', string $sr = '' ): ?array {
// Scanned checks' URLs come from the stored report, so only http(s) and relative links reach the page.
$url = esc_url_raw( $url, array( 'http', 'https' ) );
if ( '' === $url ) {
return null;
}
- return array(
+ $link = array(
'href' => $url,
'text' => '' !== $text ? $text : self::fix_link_text( $url ),
);
+ if ( '' !== $sr ) {
+ $link['sr'] = $sr;
+ }
+ return $link;
}
/**
@@ -1151,7 +1318,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
$sections[] = array(
'id' => $id,
'title' => $group[0],
- 'badge' => self::badge_data( $cant && array() === $rows ? array( 'off', __( 'Couldn’t check', 'woocommerce' ) ) : self::group_badge( $checks ) ),
+ 'badge' => self::badge_data( $cant && array() === $rows ? self::cant_check_badge() : self::group_badge( $checks, array() !== $report ) ),
'note' => 'access' === $id && ! UcpUtils::is_enabled() ? self::ucp_off_note() : ( 'understand' === $id ? self::sample_note( $report ) : null ),
'channels' => array(),
'rows' => $cant ? array_merge( $rows, array( self::cant_check_row( $launched ) ) ) : $rows,
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCopy.php b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCopy.php
index e882d5f719f..3b1b4c925eb 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCopy.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCopy.php
@@ -152,10 +152,6 @@ final class ReadinessCopy {
);
$check[4] = $fixes[ $source ] ?? $check[4];
}
- if ( 'ucp_endpoints_live' === $id && '' !== $source ) {
- /* translators: %s: HTTP status and content type, such as 403 text/html. */
- $check[3] .= ' ' . sprintf( __( 'The last answer was %s.', 'woocommerce' ), $source );
- }
return array(
'title' => $check[0],
'action' => $check[1],
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessMarkup.php b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessMarkup.php
index 4b928ed0ef0..fa0b9c65958 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessMarkup.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessMarkup.php
@@ -82,4 +82,38 @@ trait ReadinessMarkup {
// Site Health says how to move to HTTPS, and offers to do it where the host allows.
return array( $action[0], $action[1], 'https' === $check['id'] ? admin_url( 'site-health.php' ) : $check['fix_url'], '', $action[2] ?? '' );
}
+
+ /**
+ * A setup step's button, as in the design: where it goes, or Review. Policy steps repeat the same
+ * button, so screen readers also hear which policy it is for.
+ *
+ * @param string $id Store condition ID.
+ * @param string $link The link text check_action() gives when the URL alone doesn't say it, such as Change permalinks.
+ * @return array{0:string,1:string} The button text, and the policy it is for, or ''.
+ */
+ private static function step_button( string $id, string $link ): array {
+ // Policy buttons repeat, so each one's accessible name says which page it is for.
+ $policies = array(
+ 'privacy_page' => array( __( 'Choose a privacy policy page', 'woocommerce' ), __( 'Edit your privacy policy page', 'woocommerce' ) ),
+ 'terms_page' => array( __( 'Choose a terms and conditions page', 'woocommerce' ), __( 'Edit your terms and conditions page', 'woocommerce' ) ),
+ 'refund_returns_page' => array( __( 'Choose a refund and returns policy page', 'woocommerce' ), __( 'Edit your refund and returns policy page', 'woocommerce' ) ),
+ 'shipping_policy_page' => array( __( 'Choose a shipping policy page', 'woocommerce' ), __( 'Edit your shipping policy page', 'woocommerce' ) ),
+ );
+ if ( isset( $policies[ $id ] ) ) {
+ // A policy page that is still a draft opens its editor.
+ return '' !== $link ? array( __( 'Edit page', 'woocommerce' ), $policies[ $id ][1] ) : array( __( 'Choose page', 'woocommerce' ), $policies[ $id ][0] );
+ }
+ $labels = array(
+ 'https' => __( 'View Site Health', 'woocommerce' ),
+ 'launched' => __( 'Change store visibility', 'woocommerce' ),
+ 'guest_checkout' => __( 'View account settings', 'woocommerce' ),
+ 'payment_method' => __( 'View payment settings', 'woocommerce' ),
+ 'order_emails' => __( 'View email settings', 'woocommerce' ),
+ 'search_visible' => __( 'Change Reading settings', 'woocommerce' ),
+ // Change permalinks, and only when permalinks are one of the fixes.
+ 'ucp_discovery' => $link,
+ );
+ $label = $labels[ $id ] ?? '';
+ return array( '' !== $label ? $label : __( 'Review', 'woocommerce' ), '' );
+ }
}
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessRestController.php b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessRestController.php
index 1492986d00a..5730bbd10f9 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessRestController.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessRestController.php
@@ -307,9 +307,10 @@ class ReadinessRestController extends RestApiControllerBase {
'type' => array( 'string', 'null' ),
'context' => array( 'view' ),
),
- 'intro' => array(
- 'type' => array( 'string', 'null' ),
- 'context' => array( 'view' ),
+ 'checked' => array(
+ 'description' => __( 'Whether the store has been checked at least once.', 'woocommerce' ),
+ 'type' => 'boolean',
+ 'context' => array( 'view' ),
),
'run' => array(
'description' => __( 'The check button: its label, whether a check is pending or stalled, and a status message.', 'woocommerce' ),
@@ -322,6 +323,11 @@ class ReadinessRestController extends RestApiControllerBase {
'format' => 'uri',
'context' => array( 'view' ),
),
+ 'coming_soon' => array(
+ 'description' => __( 'The notice shown while the store is in coming soon mode and the results are from when it was live.', 'woocommerce' ),
+ 'type' => array( 'object', 'null' ),
+ 'context' => array( 'view' ),
+ ),
'fix_first' => array(
'type' => array( 'object', 'null' ),
'context' => array( 'view' ),
diff --git a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/AgenticCommerceSettingsTest.php b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/AgenticCommerceSettingsTest.php
index 2f367f3c5e0..8f3e1724b91 100644
--- a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/AgenticCommerceSettingsTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/AgenticCommerceSettingsTest.php
@@ -348,7 +348,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertStringNotContainsString( 'Required.', $json, 'Policy pages are recommended, so no field is marked required' );
$states = array_column( $checklist['steps'], 'state' );
$this->assertLessThan( array_search( 'open', $states, true ), max( array_keys( $states, 'required', true ) ), 'Required steps come first' );
- $this->assertSame( 'https', $checklist['steps'][0]['id'], 'HTTPS is listed first, as in the design' );
+ $this->assertSame( array( 'launched', 'https' ), array_slice( array_column( $checklist['steps'], 'id' ), 0, 2 ), 'Making the store live comes first, then HTTPS' );
$this->assertMatchesRegularExpression( '/(Choose a|Publish your) privacy policy page/', $json, 'An open check says what to do' );
$this->assertSame( 'Connection URL', $shopping['connection']['title'] );
$this->assertSame( home_url( '/.well-known/ucp' ), $shopping['connection']['url'] );
@@ -360,6 +360,46 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertNotContains( 'ucp_on', array_column( $checklist['steps'], 'id' ) );
}
+ /**
+ * @testdox Setup steps go by importance, open or done: what blocks AI shopping, then Required, then Optional.
+ */
+ public function test_setup_steps_go_by_importance_open_or_done(): void {
+ // StoreConditions' own order, plus a step the order doesn't know.
+ $ids = array( 'launched', 'search_visible', 'ucp_on', 'https', 'privacy_page', 'terms_page', 'refund_returns_page', 'shipping_policy_page', 'payment_method', 'guest_checkout', 'order_emails', 'other_step', 'ucp_discovery' );
+ $blocks = array( 'launched', 'https', 'ucp_discovery' );
+ $checks = static fn( bool $ok ): array => array_map(
+ static fn( string $id ): array => array(
+ 'id' => $id,
+ 'ok' => $ok,
+ 'blocks' => '',
+ 'level' => in_array( $id, $blocks, true ) ? StoreConditions::LEVEL_REQUIRED : StoreConditions::LEVEL_RECOMMENDED,
+ 'name' => $id,
+ 'label' => $id,
+ 'why' => '',
+ 'fix' => '',
+ 'fix_url' => '',
+ ),
+ $ids
+ );
+ $expected = array( 'launched', 'https', 'ucp_discovery', 'payment_method', 'privacy_page', 'terms_page', 'refund_returns_page', 'search_visible', 'order_emails', 'guest_checkout', 'shipping_policy_page', 'other_step' );
+
+ $this->assertSame( $expected, array_column( ReadinessCheckPage::done_steps( $checks( true ) ), 'id' ), 'Completed steps keep the same order as open ones' );
+ $this->assertSame( $expected, array_column( ReadinessCheckPage::open_steps( $checks( false ) ), 'id' ), 'Open steps: blocking, then Required, then Optional' );
+
+ // shipping_policy_page follows guest checkout in the setup list. Shown as Required, it comes first in both lists.
+ $shown = static fn( bool $ok ): array => array_map(
+ static function ( array $check ) use ( $ok ): array {
+ $check['ok'] = $ok;
+ $check['level'] = 'shipping_policy_page' === $check['id'] ? StoreConditions::LEVEL_REQUIRED : $check['level'];
+ return $check;
+ },
+ $checks( false )
+ );
+ $required_ahead = array( 'launched', 'https', 'ucp_discovery', 'payment_method', 'privacy_page', 'terms_page', 'refund_returns_page', 'search_visible', 'order_emails', 'shipping_policy_page', 'guest_checkout', 'other_step' );
+ $this->assertSame( $required_ahead, array_column( ReadinessCheckPage::done_steps( $shown( true ) ), 'id' ), 'A completed Required step stays ahead of Optional ones' );
+ $this->assertSame( $required_ahead, array_column( ReadinessCheckPage::open_steps( $shown( false ) ), 'id' ), 'An open Required step stays ahead of Optional ones' );
+ }
+
/**
* @testdox With every required check passing, open checks are only Recommended and passing ones are Done.
*/
@@ -397,7 +437,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
'not set up yet' => array( 'every_step', null, '#^Let shoppers find and buy your products through AI assistants\.$#', null, 'Set up AI shopping', '#^Your store is ready for AI shopping\. Turn it on to let AI assistants find your products\.$#' ),
'steps left' => array( 'coming_soon', 'yes', '#^AI assistants can\'t shop your store yet\. \d+ steps? left\.$#', 'Needs attention', 'Continue setup', '#^Finish \d+ required steps? to get your store ready for AI shopping\.$#' ),
'optional steps left' => array( 'optional_left', 'yes', '#^AI assistants can shop your store\. 1 step left\.$#', 'Active', 'View settings', '#^Your store is ready for AI shopping\. You have 1 optional step left\.$#' ),
- 'policy page left' => array( 'policy_left', 'yes', '#^AI assistants can shop your store\. 1 step left\.$#', 'Active', 'Continue setup', '#^Finish 1 required step to get your store ready for AI shopping\.$#' ),
+ 'policy page left' => array( 'policy_left', 'yes', '#^AI assistants can shop your store\. 1 step left\.$#', 'Needs attention', 'Continue setup', '#^Finish 1 required step to get your store ready for AI shopping\.$#' ),
'all steps done' => array( 'every_step', 'yes', '#^AI assistants can shop your store\.$#', 'Active', 'View settings', '#^Your store is ready for AI shopping\.$#' ),
'turned off' => array( 'every_step', 'no', '#^AI shopping is off\.$#', null, 'View settings', '#^Your store is ready for AI shopping\. Turn it on to let AI assistants find your products\.$#' ),
'off, steps left' => array( 'coming_soon', 'no', '#^AI shopping is off\.$#', 'Needs attention', 'Continue setup', '#^Finish \d+ required steps? to get your store ready for AI shopping\.$#' ),
@@ -437,6 +477,18 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$shopping = $this->view()['overview']['shopping'];
$this->assertMatchesRegularExpression( $checklist, $page['checklist']['summary'] );
+ if ( 'every_step' === $store ) {
+ $this->assertSame(
+ array(
+ 'intent' => 'stable',
+ 'text' => 'All steps done',
+ ),
+ $page['checklist']['badge'],
+ 'As in the design, a green badge once no step is left'
+ );
+ } else {
+ $this->assertMatchesRegularExpression( '#^\d+ steps? left$#', $page['checklist']['badge']['text'] );
+ }
$this->assertSame( 'yes' === $ucp, $page['ucp']['enabled'], 'The switch shows the setting' );
$this->assertSame( 'coming_soon' === $store, null !== $page['coming_soon'], 'Coming soon mode has its notice' );
$this->assertMatchesRegularExpression( $text, $shopping['text'] );
@@ -517,12 +569,15 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertStringNotContainsString( 'Publish your refund and returns policy page', (string) wp_json_encode( $view['sections'] ), 'A setup step stays out of the cards' );
$copy = $this->step_copy( 'refund_returns_page' );
$this->assertStringContainsString( 'post=' . $draft . '&action=edit', $copy['url'], 'Readiness check links the step to the page editor' );
- $this->assertSame( 'Edit refund policy', $copy['link'], 'named for the policy' );
+ $this->assertSame( 'Edit page', $copy['link'], 'One short button text for every policy, as in the design' );
+ $this->assertSame( 'Edit your refund and returns policy page', $copy['sr'], 'screen readers also hear which policy' );
+ $link = array_column( $view['fix_first']['items'], 'link', 'id' )['refund_returns_page'];
+ $this->assertSame( array( 'Edit page', 'Edit your refund and returns policy page' ), array( $link['text'], $link['sr'] ), 'Fix first gets both' );
$this->assertSame( 'A refund policy needs to be published for AI assistants to share it with shoppers.', $copy['text'], 'The refund draft keeps its own line' );
}
/**
- * @testdox Each draft policy page links to its editor with the policy's own link text.
+ * @testdox Each draft policy page links to its editor with Edit page, and screen readers hear which policy.
*/
public function test_draft_policy_pages_name_their_edit_link(): void {
$this->make_every_step_pass();
@@ -534,9 +589,9 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
)
);
$pages = array(
- AgenticCommerceSettings::PRIVACY_PAGE_OPTION => array( 'Publish your privacy policy page', 'Edit privacy policy', 'privacy_page', 'A privacy policy needs to be published for AI assistants to share it with shoppers.' ),
- AgenticCommerceSettings::TERMS_PAGE_OPTION => array( 'Publish your terms and conditions page', 'Edit terms and conditions', 'terms_page', 'Terms and conditions need to be published for AI assistants to share them with shoppers.' ),
- AgenticCommerceSettings::SHIPPING_POLICY_PAGE_OPTION => array( 'Publish your shipping policy page', 'Edit shipping policy', 'shipping_policy_page', 'A shipping policy needs to be published for AI assistants to share it with shoppers.' ),
+ AgenticCommerceSettings::PRIVACY_PAGE_OPTION => array( 'Publish your privacy policy page', 'Edit your privacy policy page', 'privacy_page', 'A privacy policy needs to be published for AI assistants to share it with shoppers.' ),
+ AgenticCommerceSettings::TERMS_PAGE_OPTION => array( 'Publish your terms and conditions page', 'Edit your terms and conditions page', 'terms_page', 'Terms and conditions need to be published for AI assistants to share them with shoppers.' ),
+ AgenticCommerceSettings::SHIPPING_POLICY_PAGE_OPTION => array( 'Publish your shipping policy page', 'Edit your shipping policy page', 'shipping_policy_page', 'A shipping policy needs to be published for AI assistants to share it with shoppers.' ),
);
foreach ( $pages as $option => $copy ) {
$draft = self::factory()->post->create(
@@ -549,7 +604,8 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$step = $this->step_copy( $copy[2] );
$this->assertSame( $copy[0], $step['title'] );
$this->assertStringContainsString( 'post=' . $draft . '&action=edit', $step['url'], $copy[1] );
- $this->assertSame( $copy[1], $step['link'] );
+ $this->assertSame( 'Edit page', $step['link'] );
+ $this->assertSame( $copy[1], $step['sr'] );
$this->assertSame( $copy[3], $step['text'], $copy[0] . ' says why it needs publishing, as in the design' );
wp_publish_post( $draft );
}
@@ -636,7 +692,38 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
}
/**
- * @testdox With UCP already on and a required check failing, the switch stays on and the checklist asks for the required steps, without saying assistants can shop.
+ * @testdox In coming soon mode, results from a check that ran while the store was live get a notice above Fix first; results from a check in coming soon mode don't.
+ */
+ public function test_output_coming_soon_notice_over_live_results(): void {
+ $launched = static fn( bool $ok ): array => array(
+ 'id' => 'launched',
+ 'group' => 'access',
+ 'ok' => $ok,
+ 'level' => 'required',
+ 'name' => 'Store is launched',
+ 'fix_url' => '',
+ );
+ update_option( AgentReadiness::REPORT_OPTION, array( 'store_checks' => array( $launched( true ) ) ), false );
+ $this->assertNull( $this->view()['coming_soon'], 'A live store needs no notice' );
+
+ update_option( 'woocommerce_coming_soon', 'yes' );
+ $notice = $this->view()['coming_soon'];
+ $this->assertSame( 'Your store is in coming soon mode, so AI assistants can’t find your products yet. These results are from when your store was live.', $notice['text'] );
+ $this->assertSame( 'Change store visibility', $notice['link']['text'], 'The same button as the AI shopping notice' );
+ $this->assertStringContainsString( 'site-visibility', $notice['link']['href'] );
+
+ update_option( AgentReadiness::REPORT_OPTION, array( 'store_checks' => array( $launched( false ) ) ), false );
+ $this->assertNull( $this->view()['coming_soon'], 'Results from coming soon mode say why on the cards instead' );
+
+ update_option( AgentReadiness::REPORT_OPTION, array( 'store_checks' => array() ), false );
+ $this->assertNull( $this->view()['coming_soon'], 'A report that doesn\'t say whether the store was live gets no notice' );
+
+ delete_option( AgentReadiness::REPORT_OPTION );
+ $this->assertNull( $this->view()['coming_soon'], 'No notice before the first check' );
+ }
+
+ /**
+ * @testdox With UCP already on and a required check failing, the switch stays on and the checklist asks for the required steps.
*/
public function test_output_switch_on_with_failing_checks(): void {
remove_all_filters( 'pre_option_home' );
@@ -646,7 +733,6 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertTrue( $page['ucp']['enabled'] );
$this->assertFalse( $page['ucp']['blocked'], 'It can always be turned off' );
- $this->assertSame( '', $page['ucp']['message'], 'It doesn\'t say AI assistants can shop' );
$this->assertMatchesRegularExpression( '#^Finish \d+ required steps? to get your store ready for AI shopping\.$#', $page['checklist']['summary'] );
$shopping = $this->view()['overview']['shopping'];
@@ -662,8 +748,8 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertSame( 'Continue setup', $shopping['button']['text'], 'and Continue setup opens AI shopping while a required step is left' );
$this->assertStringContainsString( 'section=shopping', $shopping['button']['href'] );
- $this->make_every_step_pass();
- $this->assertSame( 'AI shopping is on. AI assistants can now find and shop your store.', $this->shopping( true )['ucp']['message'], 'Once nothing required fails, it does' );
+ $this->assertArrayNotHasKey( 'message', $page['ucp'], 'The switch says nothing under it; it confirms a change in a snackbar' );
+ $this->assertSame( array( 'AI assistants can now shop your store.', 'AI assistants can no longer shop your store.' ), array( $page['ucp']['turned_on'], $page['ucp']['turned_off'] ), 'As in the design' );
}
/**
@@ -853,7 +939,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertSame(
array(
'intent' => 'none',
- 'text' => 'Not checked yet',
+ 'text' => 'Couldn’t check',
),
array_column( $view['sections'], 'badge', 'id' )['find'],
'Not counted as a result; the passing search engine step isn\'t in the card'
@@ -1123,7 +1209,10 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
'imported' => false,
);
update_option( AgentReadiness::REPORT_OPTION, $report );
- $this->assertSame( 'Analytics hasn\'t imported all your past orders yet, so issues are ranked by how many products and AI apps they affect. Import them in Analytics > Settings.', $this->view()['fix_first']['ranking'], 'Missing orders don\'t read as no sales' );
+ $fix_first = $this->view()['fix_first'];
+ $this->assertSame( 'Analytics hasn\'t imported all your past orders yet, so issues are ranked by how many products and AI apps they affect.', $fix_first['ranking'], 'Missing orders don\'t read as no sales' );
+ $this->assertSame( 'Import your past orders in Analytics settings', $fix_first['link']['text'], 'The link goes where the import is' );
+ $this->assertStringEndsWith( 'admin.php?page=wc-admin&path=/analytics/settings', $fix_first['link']['href'] );
unset( $report['sales'] );
update_option( AgentReadiness::REPORT_OPTION, $report );
@@ -1206,7 +1295,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$sections = array_column( $this->view()['sections'], null, 'id' );
foreach ( array( 'products', 'understand' ) as $id ) {
- $this->assertSame( 'No products', $sections[ $id ]['badge']['text'], $id . ' says why it has no checks' );
+ $this->assertSame( 'Couldn’t check', $sections[ $id ]['badge']['text'], $id . ' has no checks; its text says why' );
$this->assertSame( array(), array_merge( $sections[ $id ]['rows'], $sections[ $id ]['folded'] ) );
$this->assertSame( 'You don’t have any products yet', $sections[ $id ]['empty']['title'] );
$this->assertSame( 'Add a product', $sections[ $id ]['empty']['link']['text'] );
@@ -1242,7 +1331,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
private function assert_products_are_unreadable(): void {
$sections = array_column( $this->view()['sections'], null, 'id' );
foreach ( array( 'products', 'understand' ) as $id ) {
- $this->assertSame( 'Not checked', $sections[ $id ]['badge']['text'], $id );
+ $this->assertSame( 'Couldn’t check', $sections[ $id ]['badge']['text'], $id );
$this->assertSame( 'None of your products can be checked yet', $sections[ $id ]['empty']['title'] );
$this->assertSame( 'View product visibility', $sections[ $id ]['empty']['link']['text'] );
$this->assertStringContainsString( 'section=' . AgenticCommerceSettings::SHOPPING_SECTION, $sections[ $id ]['empty']['link']['href'] );
@@ -1373,20 +1462,21 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
}
/**
- * @testdox A question's badge counts its issues; a check that couldn't run isn't an issue, nor a pass.
+ * @testdox A question's badge counts its issues; when nothing failed but a check couldn't run, it says Couldn't check; before the first check, Not checked yet.
*/
public function test_group_badge(): void {
$badge = new \ReflectionMethod( ReadinessCheckPage::class, 'group_badge' );
$badge->setAccessible( true );
- $text = static fn( array $checks ): string => $badge->invoke( null, $checks )[1];
+ $text = static fn( array $checks, bool $checked = true ): string => $badge->invoke( null, $checks, $checked )[1];
$row = static fn( ?bool $ok ): array => array( 'ok' => $ok );
$this->assertSame( '2 issues', $text( array( $row( false ), $row( false ), $row( true ) ) ) );
$this->assertSame( '1 issue', $text( array( $row( false ), $row( null ) ) ) );
$this->assertSame( 'All passed', $text( array( $row( true ), $row( true ) ) ) );
- $this->assertSame( 'No issues', $text( array( $row( true ), $row( null ) ) ), 'A check that could not run is not an issue, nor a pass' );
- $this->assertSame( 'Not checked yet', $text( array() ) );
- $this->assertSame( 'Not checked yet', $text( array( $row( null ), $row( null ) ) ), 'Nothing ran, so nothing is shown as passed' );
+ $this->assertSame( 'Couldn’t check', $text( array( $row( true ), $row( null ) ) ), 'A check that could not run is not an issue, nor a pass' );
+ $this->assertSame( 'Couldn’t check', $text( array( $row( null ), $row( null ) ) ), 'Nothing ran, so nothing is shown as passed' );
+ $this->assertSame( 'Couldn’t check', $text( array() ) );
+ $this->assertSame( 'Not checked yet', $text( array( $row( null ) ), false ), 'Before the first check' );
$map = new \ReflectionMethod( ReadinessCheckPage::class, 'badge_data' );
$map->setAccessible( true );
@@ -1421,7 +1511,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
WC_Helper_Product::create_simple_product();
WC_Helper_Product::create_simple_product();
wc_get_container()->get( AgentReadiness::class )->refresh_report();
- $this->row( 'Add a brand to 4 products' );
+ $this->assertStringContainsString( 'agent_readiness=', $this->row( 'Add a brand to 4 products' )['link']['href'], 'Several products open the Products list filtered to them' );
$counted = array_filter( (array) $this->view()['fix_first']['items'], static fn( array $item ): bool => false !== strpos( $item['title'], ' 4 products' ) );
$this->assertNotEmpty( $counted, 'Fix first has a product fix that counts the products' );
}
@@ -1460,9 +1550,8 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertStringNotContainsString( 'Required by', $json );
$this->assertStringNotContainsString( 'Harder to find on', $json, 'Only channels that can\'t list the product are tagged' );
$this->assertSame( 'View product', $brand['link']['text'], 'One product, as in the design' );
- $this->assertStringContainsString( 'agent_readiness=', $brand['link']['href'], 'The link opens the Products list filtered to the failing products' );
+ $this->assertStringContainsString( 'post=' . $product->get_id() . '&action=edit', $brand['link']['href'], 'One product opens its edit page, not a list of one' );
$this->assertStringNotContainsString( 'main image has no alt text', $json, 'Store readiness covers alt text' );
- $this->assertStringNotContainsString( 'post=' . $product->get_id(), $json, 'No example products' );
$this->assertSame( 'Let search engines index your store', $this->step( $this->shopping(), 'search_visible' )['title'], 'Hidden from search engines is a setup step' );
$this->assertNull( $view['checked_note'] );
@@ -1543,7 +1632,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertSame(
array(
'intent' => 'none',
- 'text' => 'Not checked yet',
+ 'text' => 'Couldn’t check',
),
$badges['access'],
'With AI shopping off and no scanned access check, the card has nothing checked; setup steps stay out'
@@ -1627,7 +1716,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
update_option( 'woocommerce_enable_guest_checkout', 'no' );
$shopping = $this->shopping();
$this->assertStringStartsWith( 'Finish 3 required steps', $shopping['checklist']['summary'] );
- $this->assertSame( array( 'search_visible', 'payment_method', 'order_emails', 'guest_checkout' ), array_column( $shopping['checklist']['steps'], 'id' ), 'They come before the optional guest checkout step' );
+ $this->assertSame( array( 'payment_method', 'search_visible', 'order_emails', 'guest_checkout' ), array_column( $shopping['checklist']['steps'], 'id' ), 'They come before the optional guest checkout step' );
$this->assertSame( array( 'required', 'required', 'required', 'open' ), array_column( $shopping['checklist']['steps'], 'state' ), 'All three stay Required (WOOAI-1681)' );
foreach ( array(
'search_visible' => array( 'Let search engines index your store', 'Change Reading settings' ),
@@ -1739,9 +1828,9 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
}
/**
- * @testdox With AI shopping on, a failing connection URL is Required and in Fix first, and failing catalog search is a Warning that says what came back.
+ * @testdox With AI shopping on, a failing connection URL is Required and in Fix first, and failing catalog search has no badge, like any failing check that isn't Required, with the status code kept off the page.
*/
- public function test_failing_ucp_profile_is_required_and_endpoint_a_warning(): void {
+ public function test_failing_ucp_profile_is_required_and_endpoint_not(): void {
$this->make_every_step_pass();
update_option( 'woocommerce_feature_ucp_enabled', 'yes' );
$row = static fn( string $id ): array => array(
@@ -1769,18 +1858,12 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$view = $this->view();
$items = array_column( $view['fix_first']['items'], 'tier', 'id' );
$this->assertSame( 'Required for AI shopping', $items['ucp_profile'] );
- $this->assertArrayNotHasKey( 'ucp_endpoints_live', $items, 'Catalog search can fail now and then with nothing changed, so it warns instead' );
+ $this->assertArrayNotHasKey( 'ucp_endpoints_live', $items, 'Catalog search can fail now and then with nothing changed, so it is not Required' );
$this->assertArrayNotHasKey( 'ucp_profile_version', $items, 'A different version is likely another plugin, not a blocker' );
$rows = array_column( array_column( $view['sections'], null, 'id' )['access']['rows'], null, 'id' );
$this->assertSame( 'Required', $rows['ucp_profile']['badge']['text'] );
- $this->assertSame(
- array(
- 'intent' => 'medium',
- 'text' => 'Warning',
- ),
- $rows['ucp_endpoints_live']['badge']
- );
- $this->assertStringEndsWith( 'The last answer was 403 text/html.', $rows['ucp_endpoints_live']['text'] );
+ $this->assertNull( $rows['ucp_endpoints_live']['badge'] );
+ $this->assertStringNotContainsString( '403', $rows['ucp_endpoints_live']['text'], 'The status code is for support, not the merchant' );
}
/**
@@ -1867,13 +1950,13 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$this->assertSame( 'Not checked yet', $view['last_checked'], 'No check has run' );
$this->assertSame( 'Check your store', $view['run']['label'], 'and the page offers to run one' );
$this->assertFalse( $view['run']['pending'] );
- $this->assertSame( 'Run a check to see what AI assistants get when they visit your store and read your products.', $view['intro'], 'No results before the first scan' );
+ $this->assertFalse( $view['checked'], 'No results before the first scan' );
$this->assertSame( array(), $view['sections'] );
$this->assertNull( $view['fix_first'] );
wc_get_container()->get( ScheduledScan::class )->queue();
$run = $this->view()['run'];
- $this->assertSame( 'Checking your store.', $run['message'], 'Read out to screen readers; the page shows a spinner' );
+ $this->assertSame( 'Checking your store', $run['message'], 'Shown beside a spinner' );
$this->assertTrue( $run['pending'] );
$this->assertFalse( $run['stalled'], 'A queued check is not stalled, so the page keeps polling' );
@@ -2538,6 +2621,7 @@ class AgenticCommerceSettingsTest extends WC_Unit_Test_Case {
$shopping = $this->shopping();
$this->assertSame( 'Learn how it works', $shopping['ucp']['learn_more']['text'] );
+ $this->assertSame( 'https://woocommerce.com/document/woocommerce-ai/agentic-commerce/', $shopping['ucp']['learn_more']['href'], 'The doc for setting up AI shopping' );
$this->assertSame( '/wc/v3/agent-readiness/ucp', $shopping['ucp']['path'], 'The switch saves on its own, as before' );
$this->assertSame( 'Test the connection in UCP Playground', $shopping['connection']['test']['text'] );
$this->assertSame( 'https://ucpplayground.com', $shopping['connection']['test']['href'] );
diff --git a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ReadinessCheckPageTest.php b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ReadinessCheckPageTest.php
index 8902b24efbb..4befd7bf3b2 100644
--- a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ReadinessCheckPageTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ReadinessCheckPageTest.php
@@ -202,10 +202,38 @@ class ReadinessCheckPageTest extends WC_Unit_Test_Case {
'product' => $product->get_id(),
);
- $this->assertStringStartsWith( 'On the Blue hoodie & cap page, the name, price, and stock aren’t in the page code', $failing_copy->invoke( null, $check )['text'] );
+ $named = $failing_copy->invoke( null, $check );
+ $this->assertStringStartsWith( 'On the Blue hoodie & cap page, the name, price, and stock aren’t in the page code', $named['text'] );
+ $this->assertSame( 'Blue hoodie & cap', $named['tool']['text'], 'The product name is the linked text' );
+ $this->assertSame( get_permalink( $product->get_id() ), $named['tool']['href'], 'The name links to the product page that failed' );
+ $this->assertSame( 7, $named['tool']['at'], 'The link starts after "On the "' );
+
+ $product->set_name( 'the' );
+ $product->save();
+ $this->assertSame( 7, $failing_copy->invoke( null, $check )['tool']['at'], 'A name that is also an earlier word in the line is linked where the name is' );
+
+ $translate = static function ( $translation, $text ) {
+ return 0 === strpos( (string) $text, 'On the %s page, the name, price, and stock' ) ? 'Na stronie „%s” brakuje nazwy, ceny i stanu.' : $translation;
+ };
+ add_filter( 'gettext', $translate, 10, 2 );
+ $translated = $failing_copy->invoke( null, $check );
+ remove_filter( 'gettext', $translate, 10 );
+ $this->assertSame( 'Na stronie „the” brakuje nazwy, ceny i stanu.', $translated['text'] );
+ $this->assertSame( 12, $translated['tool']['at'], 'In a translation the name can sit elsewhere, and the position counts characters, not bytes' );
+
+ $emoji = static function ( $translation, $text ) {
+ return 0 === strpos( (string) $text, 'On the %s page, the name, price, and stock' ) ? '😀 On the %s page, the name.' : $translation;
+ };
+ add_filter( 'gettext', $emoji, 10, 2 );
+ $emoji_line = $failing_copy->invoke( null, $check );
+ remove_filter( 'gettext', $emoji, 10 );
+ $this->assertSame( '😀 On the the page, the name.', $emoji_line['text'] );
+ $this->assertSame( 10, $emoji_line['tool']['at'], 'An emoji before the name counts as two UTF-16 code units, the index the page slices with' );
$product->delete( true );
- $this->assertStringStartsWith( 'On a product page, the name, price, and stock aren’t in the page code', $failing_copy->invoke( null, $check )['text'] );
+ $unnamed = $failing_copy->invoke( null, $check );
+ $this->assertStringStartsWith( 'On a product page, the name, price, and stock aren’t in the page code', $unnamed['text'] );
+ $this->assertNull( $unnamed['tool'], 'A deleted product has no link' );
$check['id'] = 'viewport_meta';
$this->assertStringStartsWith( 'On a product page, the code doesn’t tell browsers how to size it', $failing_copy->invoke( null, $check )['text'], 'A check that also reads the home page doesn\'t blame it for a deleted product\'s page' );