Option to display stars as a link with number of reviews

Created on 28 March 2025, 4 months ago

Problem/Motivation

Currently there's an option to display a link with the stars but no shorthand display like most stores use where it shows the stars and the number of reviews in parenthesis. Then the whole thing is a link to the reviews.

★★★★★ (23)

Steps to reproduce

Proposed resolution

Add a configuration option to Overall Rating to display the stars as a link with review count.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States rhovland Oregon

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @rhovland
  • 🇺🇸United States rhovland Oregon

    Feature done. Needs the schema updated and an update hook written to migrate setting "show_overview_link" to "link_display" = "overview"

  • 🇮🇳India chhavi.sharma

    Hi @rhovland,
    You are saying that the feature is done but when I selected stars option in view display and selected shorthand link option.
    It is not showing any stars, just a link of all reviews with the reviews count.

    So can you please clarify what has been accomplished and what is needed to be done here?

  • 🇺🇸United States rhovland Oregon

    Apologies I had opened this issue to push my code and fell asleep before I finished. I pushed them in the morning. The actual feature this issue is for is done. The only thing remaining to do was the update hook so that existing site configuration is migrated over to the new structure. Also I had not made any changes to the configuration schema file yet which needs to be updated to reflect the changes in configuration.

    If the stars aren't displaying then that means the rateit library isn't loading. It's displaying like this on my dev site

  • 🇺🇸United States rhovland Oregon

    Missed a line of code where $rating_element was being set. Link now properly generates.

    Still wouldn't explain your problem of stars not showing up since the old code was still creating the rating element. Think it's probably the javascript library missing.

  • Merge request !12Resolve #3515935 "Option to display" → (Merged) created by chhavi.sharma
  • 🇮🇳India chhavi.sharma

    The update_hook has been implemented and schema has been updated. The issue needs review.

  • 🇺🇸United States rhovland Oregon
  • Status changed to Needs work 29 days ago
  • 🇺🇸United States rhovland Oregon

    The update hook does not work. The configuration is not changed and the old configuration remains after it is ran.

  • 🇦🇹Austria agoradesign

    It cannot work imho, because there are no configs with "commerce_product_review_overall_rating_stars" in its name.

    I believe, the correct way to update field formatter settings, is to first identify the field instances it may concern (we have it as base field on commerce_product entity, but maybe we should search potentially available additional fields in other fieldable entities, as the data model does not restrict its usage (if this was ever used and tested at all, is a different question)).
    When we have every concerning field instances, go through all configured entity view display configurations of that entity, and check, if this field component is enabled at all. If so, do the change and save it.

  • 🇺🇸United States rhovland Oregon

    Yeah there will never be a field.formatter.commerce_product_review_overall_rating_stars because that's only used for fields added to an entity. And the display settings are not stored there.

    They're stored in the core.entity_view_display.{entity_name}.default.default, in this case core.entity_view_display.commerce_product.default.default.yml for a default install. If there are other product types or product view modes there will be additional places to update the configuration.

    While it's technically possible to add this overall rating field type to other entities, they will not work because the all of the field code expects there to be a product entity. We probably should add checks for that to prevent broken config forms if admins accidentally add it to other entities in a separate issue. There doesn't seem to be a way to restrict fields to certain entity types.

  • 🇺🇸United States rhovland Oregon

    Ok I think this is good to go, just need to review the changes again on monday with a fresh set of eyes

  • Pipeline finished with Skipped
    23 days ago
    #529467
  • 🇺🇸United States rhovland Oregon
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024