Skip to content

Enable product rating in snippet preview #2781#22954

Merged
d-claassen merged 15 commits intotrunkfrom
2781-enable-product-rating-in-snippet-preview
Mar 2, 2026
Merged

Enable product rating in snippet preview #2781#22954
d-claassen merged 15 commits intotrunkfrom
2781-enable-product-rating-in-snippet-preview

Conversation

@mykola
Copy link
Contributor

@mykola mykola commented Feb 6, 2026

Context

  • Update the Snippet Preview to allow customization of the bestRating value and its visual representation in line with the visual presention in Google SERPs.

Summary

This PR can be summarized in the following changelog entry:

  • [@yoast/search-metadata-previews 3.0.0-alpha.3 enhancement] Support new bestRating value on the shoppingData input.
  • [@yoast/search-metadata-previews 3.0.0-alpha.3 enhancement] Change default visual presentation to a rating out of 5, without showing the best rating.
  • Updates the Google Preview on WooCommerce product pages to show the rating as best out of 5, in line with how SERPs visualize the schema structure generated by Woocommerce. This change only applies when Yoast WooCommerce SEO is installed.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

  • Install Yoast SEO Premium and Yoast Woocommerce SEO
  • Configure your Woocommerce shop and add a product
  • Configure Woocommerce > Settings > Products > General to Enable reviews and Enable star rating on reviews
  • Visit your product in your shop and leave one or more reviews with a star rating
  • Check the Woocommerce schema.org markup for your product to find the aggregateRating:
    "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "4.67",
        "reviewCount": 4
    },
  • In the edit product page find the Google Preview in the Yoast SEO metabox.
  • Confirm the rating section is showing in the format {rating} {5 stars} {#amount of reviews}

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:

  • Please check that wordpress Snippet Preview still works correctly.
  • Please check that woocommerce Snippet Preview still works as expected.

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.
  • This PR also affects Yoast SEO for Google Docs. I have added a changelog entry starting with [yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached the Google Docs Add-on label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

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.
  • I have run grunt build:images and commited the results, if my PR introduces new images or SVGs.

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 #2781

#2781
Update Snippet Preview according to the Google structured data guidelines for AggregateRating / Rating
@mykola mykola added the Shopify This PR impacts Shopify. label Feb 6, 2026
@coveralls
Copy link

coveralls commented Feb 6, 2026

Pull Request Test Coverage Report for Build 06e77cb348a7904a627c684d26e5c9a92c8ac8b9

Details

  • 6 of 7 (85.71%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-3.9%) to 49.801%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/js/src/redux/reducers/shoppingData.js 0 1 0.0%
Totals Coverage Status
Change from base Build 78303363c441ae21d185a09c117cfa3e007fbaba: -3.9%
Covered Lines: 5427
Relevant Lines: 10975

💛 - Coveralls

@mykola mykola marked this pull request as ready for review February 9, 2026 10:12
@mykola mykola added the changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog label Feb 9, 2026
@konradyoast konradyoast self-assigned this Feb 11, 2026
@konradyoast konradyoast requested a review from Copilot February 11, 2026 15:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Snippet Preview product rich-result UI to comply with Google structured data guidelines for AggregateRating / Rating by introducing bestRating and adjusting the rating display and star scaling.

Changes:

  • Added a shared DEFAULT_BEST_RATING constant and plumbed bestRating through snippet preview shopping data.
  • Updated mobile/desktop product data rendering to optionally display rating/bestRating and scale stars to a 5-star component.
  • Extended Redux shoppingData reducer and updated SnippetEditor tests to include bestRating.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
packages/search-metadata-previews/src/snippet-preview/constants.js Introduces DEFAULT_BEST_RATING for consistent rating normalization.
packages/search-metadata-previews/src/snippet-preview/SnippetPreview.js Ensures bestRating is always present in the constructed shoppingData passed to subcomponents.
packages/search-metadata-previews/src/snippet-preview/ProductDataMobile.js Updates rating rendering rules, scaling, and display formatting on mobile.
packages/search-metadata-previews/src/snippet-preview/ProductDataDesktop.js Updates rating rendering rules, scaling, and display formatting on desktop.
packages/js/tests/containers/SnippetEditor.test.js Updates test fixtures to include bestRating.
packages/js/src/redux/reducers/shoppingData.js Persists bestRating in Redux shopping data state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@konradyoast konradyoast left a comment

Choose a reason for hiding this comment

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

LGTM, but please check copilot comments @mykola 🟢

mykola and others added 3 commits February 11, 2026 12:23
…ataMobile.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
#2781
Fix comments
Unit tests implemented.
@mykola mykola requested a review from Copilot February 12, 2026 07:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@konradyoast konradyoast left a comment

Choose a reason for hiding this comment

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

thanks for changes, lgtm !

@konradyoast konradyoast requested a review from Copilot February 17, 2026 16:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@d-claassen d-claassen added this to the 27.2 milestone Mar 2, 2026
Copy link
Contributor

@d-claassen d-claassen left a comment

Choose a reason for hiding this comment

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

✅ CR done and tested.

@d-claassen d-claassen merged commit 4ff1bc1 into trunk Mar 2, 2026
27 of 28 checks passed
@d-claassen d-claassen deleted the 2781-enable-product-rating-in-snippet-preview branch March 2, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog Shopify This PR impacts Shopify.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants