# fluent-cart/trunk/assets/ProductRatingBlockEditor.js

FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler, version trunk. 2 lines.

- Page: https://pluginprobe.com/plugins/fluent-cart/trunk/code/assets/ProductRatingBlockEditor.js
- Raw: https://pluginprobe.com/plugins/fluent-cart/trunk/raw/assets/ProductRatingBlockEditor.js
- Modified: 2026-09-29T12:49:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-cart/trunk/code/assets/ProductRatingBlockEditor.js#L10-L20`.

```javascript
import{j as e}from"./chunks/jsx-runtime.js?ver=1.7.0";import{b as i}from"./chunks/BlockEditorTranslator.js?ver=1.7.0";import{E as b}from"./chunks/EditorPanel.js?ver=1.7.0";import{E}from"./chunks/EditorPanelRow.js?ver=1.7.0";import{R as P,u as H,a as M}from"./chunks/reviewBlockShared.js?ver=1.7.0";import{o as S}from"./chunks/Icons.js?ver=1.7.0";import"./chunks/SelectProductModal.js?ver=1.7.0";import"./chunks/index6.js?ver=1.7.0";import"./chunks/ProductListItem.js?ver=1.7.0";import"./chunks/index5.js?ver=1.7.0";import"./chunks/add-query-args.js?ver=1.7.0";import"./chunks/SingleProductContext.js?ver=1.7.0";const{InspectorControls:I}=wp.blockEditor,{__experimentalNumberControl:_}=wp.components,q=({attributes:r,setAttributes:o,selectedProduct:p,setSelectedProduct:d,insideParent:s})=>e.jsx(I,{children:e.jsx("div",{className:"fct-inspector-control-wrap fct-inspector-control-wrap--product-card fct-inspector-control-wrap--product-rating",children:e.jsx("div",{className:"fct-inspector-control-group",children:e.jsxs("div",{className:"fct-inspector-control-body",children:[!s&&e.jsx(P,{attributes:r,setAttributes:o,selectedProduct:p,setSelectedProduct:d}),e.jsx(b,{title:i("Visibility"),children:e.jsxs(E,{className:"flex-col",children:[e.jsx(_,{label:i("Minimum Reviews"),help:i("Hide the rating until the product has at least this many reviews. 0 always shows it, including five empty stars on a product with none."),value:r.minReviewCount,min:0,step:1,onChange:t=>{const n=parseInt(t,10);o({minReviewCount:isNaN(n)||n<0?0:n})}}),e.jsx(_,{label:i("Minimum Average Rating"),help:i("Hide the rating unless the product averages at least this many stars. 0 shows every rating. Half stars are allowed."),value:r.minAverageRating,min:0,max:5,step:.5,onChange:t=>{const n=parseFloat(t);if(isNaN(n)||n<0){o({minAverageRating:0});return}o({minAverageRating:Math.min(5,n)})}})]})})]})})})}),{useBlockProps:B}=wp.blockEditor,{registerBlockType:F}=wp.blocks,l=window.fluent_cart_product_rating_data;F(l.slug+"/"+l.name,{apiVersion:3,title:l.title,description:l.description,icon:{src:S},category:"fluent-cart",attributes:{query_type:{type:"string",default:"default"},product_id:{type:["string","number"],default:""},minReviewCount:{type:"number",default:0},minAverageRating:{type:"number",default:0}},edit:({attributes:r,setAttributes:o,clientId:p})=>{var v,w,y,x;const d=B({className:"fct-product-rating-block-editor"}),s=H(p),{selectedProduct:t,setSelectedProduct:n}=M(r,s,!1);wp.element.useEffect(()=>{s&&r.query_type!=="default"&&o({query_type:"default"})},[s,r.query_type]);const u=((w=(v=t==null?void 0:t.detail)==null?void 0:v.other_info)==null?void 0:w.average_rating)||0,f=((x=(y=t==null?void 0:t.detail)==null?void 0:y.other_info)==null?void 0:x.review_count)||0,N=c=>{const R=[];for(let a=1;a<=5;a++){const j=a<=Math.floor(c),k=!j&&a===Math.floor(c)+1&&c-Math.floor(c)>=.5;let m="fct-star fct-star-empty";j?m="fct-star fct-star-filled":k&&(m="fct-star fct-star-half"),R.push(e.jsx("span",{className:m,children:"★"},a))}return R},h=parseInt(r.minReviewCount,10)||0,g=parseFloat(r.minAverageRating)||0,C=h>0&&f<h||g>0&&u<g;return e.jsxs("div",{...d,children:[e.jsx(q,{attributes:r,setAttributes:o,selectedProduct:t,setSelectedProduct:n,insideParent:s}),C?e.jsx("span",{className:"fct-product-rating-block-editor-hidden",children:i("Hidden — this product is below the thresholds set here")}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fct-product-card-stars",children:N(u)}),e.jsxs("span",{className:"fct-product-card-review-count",children:["(",f,")"]})]})]})},save:function(){return null},supports:{html:!1,align:["left","center","right"],typography:{fontSize:!0,lineHeight:!0,__experimentalDefaultControls:{fontSize:!0}},color:{text:!0},spacing:{margin:!0,padding:!0}}});

```
