Skip to content

Adds an upsell for AI Optimize on products#22254

Merged
FAMarfuaty merged 2 commits intofeature/ai-optimize-classicfrom
fix/ai-optimize-woo-upsell
May 13, 2025
Merged

Adds an upsell for AI Optimize on products#22254
FAMarfuaty merged 2 commits intofeature/ai-optimize-classicfrom
fix/ai-optimize-woo-upsell

Conversation

@mhkuu
Copy link
Copy Markdown
Contributor

@mhkuu mhkuu commented May 12, 2025

Context

Summary

This PR can be summarized in the following changelog entry:

  • Ensures that AI Optimize on WooCommerce products can only be used with Yoast SEO Premium and Yoast WooCommerce SEO active, shows an upsell otherwise.

Relevant technical choices:

  • We're reusing the code in AI Generate to retrieve the correct upsell properties.

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

Note

While testing the AI Optimize upsell, smoke test the AI Generate upsell as well, see #22214 for the testing steps.

Prerequisites

  • Create a WooCommerce product that has any AI Optimize button active.
  • For example, create product that has an introduction, but a keyphrase that does not appear in that introduction.

Test the Yoast SEO Premium upsell

  • Make sure Yoast SEO Premium is deactivated, but Yoast WooCommerce SEO is activated.
  • Confirm clicking the AI Optimize button opens an upsell modal.
  • It should prompt you to buy Yoast SEO Premium, like this:
    Screenshot 2025-05-12 at 09 00 23
  • Inspect the big yellow upsell button.
  • Confirm the shortlink starts with https://yoa.st/ai-fix-assessments-upsell.
  • Confirm the CTB id is f6a84663-465f-4cb5-8ba5-f7a6d72224b2.

Test the Yoast WooCommerce SEO upsell

  • Make sure Yoast SEO Premium is activated, but Yoast WooCommerce SEO is activated.
  • Confirm clicking the AI Optimize button opens an upsell modal.
  • It should prompt you to buy Yoast WooCommerce SEO, like this:
    Screenshot 2025-05-12 at 09 00 43
  • Inspect the big yellow upsell button.
  • Confirm the shortlink starts with https://yoa.st/ai-fix-assessments-upsell-woo-seo.
  • Confirm the CTB id is 5b32250e-e6f0-44ae-ad74-3cefc8e427f9.

Test the bundle upsell

  • Make sure Yoast SEO Premium and Yoast WooCommerce SEO are both deactivated.
  • Confirm clicking the AI Optimize button opens an upsell modal.
  • It should prompt you to buy the bundle, like this:
    Screenshot 2025-05-12 at 09 00 03
  • Inspect the big yellow upsell button.
  • Confirm the shortlink starts with https://yoa.st/ai-fix-assessments-upsell-woo-seo-premium-bundle.
  • Confirm the CTB id is c7e7baa1-2020-420c-a427-89701700b607.

Test the happy path

  • Activate Yoast SEO Premium and Yoast WooCommerce SEO.
  • Confirm the Toast loads when clicking the AI Optimize button.

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • The upsell modals for AI Generate and AI Optimize.

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/wordpress-seo-premium/issues/4627

@mhkuu mhkuu added this to the feature/ai-optimize-classic milestone May 12, 2025
@mhkuu mhkuu added the changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog label May 12, 2025
@mhkuu mhkuu marked this pull request as ready for review May 12, 2025 07:05
Comment on lines +90 to +97
// Use specific copy for product posts.
const isWooCommerceActive = useSelect( select => select( STORE ).getIsWooCommerceActive(), [] );
const isProductPost = useSelect( select => select( STORE ).getIsProduct(), [] );

if ( isWooCommerceActive && isProductPost ) {
upsellProps.title = __( "Generate product titles & descriptions with AI!", "wordpress-seo" );
upsellProps.isProductCopy = true;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this out of the getUpsellProps function as this is specific for AI Generate.

@coveralls
Copy link
Copy Markdown

coveralls commented May 12, 2025

Pull Request Test Coverage Report for Build b48403485f0e8008840de72c40ded487fab96ba9

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 5 of 25 (20.0%) changed or added relevant lines in 3 files are covered.
  • 4 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.2%) to 53.035%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/js/src/ai-optimizer/components/modal-content.js 0 6 0.0%
packages/js/src/ai-generator/components/modal-content.js 2 16 12.5%
Files with Coverage Reduction New Missed Lines %
packages/dashboard-frontend/src/constants.js 1 50.0%
packages/dashboard-frontend/src/services/remote-data-provider.js 1 92.86%
packages/js/src/ai-optimizer/components/modal-content.js 1 13.33%
packages/js/src/editor-modules.js 1 0.0%
Totals Coverage Status
Change from base Build 3ce79a706865855e280214baf32106152d113129: 0.2%
Covered Lines: 29623
Relevant Lines: 57033

💛 - Coveralls


const postModalprops = {
upsellLink: upsellLinkPremium,
title: __( "Fix assessments with AI!", "wordpress-seo" ),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was an old variable that is not used anymore? I couldn't find it anywhere anymore 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, didn't see it used anywhere 😅

Comment thread packages/js/tests/ai-optimizer/components/ai-optimize-button.test.js Outdated
@FAMarfuaty
Copy link
Copy Markdown
Contributor

CR: Code looks good! 🙌🏽
Good job with adding type definition for the upsell props, and also with fixing the ESLint's max statements and complexity issues in packages/js/src/ai-generator/components/modal-content.js

@FAMarfuaty
Copy link
Copy Markdown
Contributor

Acceptance test: works as expected! 🙌🏽

@FAMarfuaty FAMarfuaty merged commit 15936d2 into feature/ai-optimize-classic May 13, 2025
19 checks passed
@FAMarfuaty FAMarfuaty deleted the fix/ai-optimize-woo-upsell branch May 13, 2025 08:35
@FAMarfuaty
Copy link
Copy Markdown
Contributor

I've also updated the feature documentation here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: non-user-facing Needs to be included in the 'Non-userfacing' category in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants