feat(reviews): conditionally display reviews based on display settings#2754
feat(reviews): conditionally display reviews based on display settings#2754matthewvolk merged 1 commit intocanaryfrom
Conversation
🦋 Changeset detectedLatest commit: 77c1e77 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
cf9d614 to
681a718
Compare
681a718 to
c86f7e1
Compare
c86f7e1 to
5c4934f
Compare
matthewvolk
left a comment
There was a problem hiding this comment.
Note + question I had while working on this one
| const baseProduct = await getProduct(productId, customerAccessToken); | ||
| const { product: baseProduct, settings } = await getProduct(productId, customerAccessToken); | ||
|
|
||
| const reviewsEnabled = Boolean(settings?.reviews.enabled && !settings.display.showProductRating); |
There was a problem hiding this comment.
Not sure if this var name is confusing... it's supposed to represent that reviews can still be left on a product even if the merchant has disabled "Show product ratings on my store" in their display settings.
There was a problem hiding this comment.
reviewSubmissionEnabled? 🍹
| reviewFormEmailLabel?: string; | ||
| reviewFormModalTitle?: string; | ||
| reviewFormNameLabel?: string; | ||
| reviewFormRatingLabel?: string; | ||
| reviewFormReviewLabel?: string; | ||
| reviewFormSubmitLabel?: string; | ||
| reviewFormTitleLabel?: string; | ||
| reviewFormAction: SubmitReviewAction; | ||
| user: Streamable<{ email: string; name: string }>; |
There was a problem hiding this comment.
New props required to render ReviewForm ("Write a review" form) when Review Display setting is disabled, but Product Review functionality is enabled (this is done to match Stencil behavior)
bookernath
left a comment
There was a problem hiding this comment.
Non-blocking comments, most important is probably to have a think about how international names may be affected by "first + last initial" treatment (will that ever break?)
| const baseProduct = await getProduct(productId, customerAccessToken); | ||
| const { product: baseProduct, settings } = await getProduct(productId, customerAccessToken); | ||
|
|
||
| const reviewsEnabled = Boolean(settings?.reviews.enabled && !settings.display.showProductRating); |
There was a problem hiding this comment.
reviewSubmissionEnabled? 🍹
| const firstName = session?.user?.firstName ?? ''; | ||
| const lastName = session?.user?.lastName ?? ''; | ||
|
|
||
| if (!firstName || !lastName) { |
There was a problem hiding this comment.
consider if (!firstName && !lastName) 🍹
crazy edge case but suppose only one name was populated... is that still a valid user?
| return { email: session?.user?.email ?? '', name: '' }; | ||
| } | ||
|
|
||
| const lastInitial = lastName.charAt(0).toUpperCase(); |
There was a problem hiding this comment.
🍹 internationalization considerations?
5c4934f to
77c1e77
Compare
Warning
Depends on #2752 and #2753
What/Why?
Conditionally display product ratings based on
site.settings.display.showProductRating. Ratings only show when bothreviews.enabledanddisplay.showProductRatingare true, matching Stencil + Cornerstone behavior.Updates brand, category, search, and product pages to query and respect the display setting. Product detail page separates review form visibility (
reviewsEnabled) from rating display (showRating).Testing
showProductRatingis enabledshowProductRatingis disabledreviews-enabled-show-rating-disabled.mov
reviews-enabled-show-rating-enabled.mov
reviews-disabled.mov
Migration
No migration needed. This adds a new GraphQL field (
display.showProductRating) and conditional logic. Existing behavior unchanged if setting not configured.Note: This pull request description was generated with the assistance of AI.