How do I dynamically update the JSON-LD Script for the Schema type = Product

732 views Asked by At

I have the following script, my question is given after the script.

 <script type="application/ld+json">
 {
  "@context": "http://schema.org/",
  "@type": "Product",
  "name": "Coffee Mug",

  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "4.9",
    "ratingCount": "77"
  },
  "offers": {
    "@type": "AggregateOffer",
    "lowPrice": "5.76",
    "highPrice": "8",
    "availability": "http://schema.org/InStock",
    "priceCurrency": "USD"
  }
}

I want to make sure that once the Star Rating is changed, it should also be changed in the script.

So can you please let me know how to do it?

MY Question is:

I am using a widget for star rating. Right now there are 77 votes and aggregate rating is 4.9 out of 5.

Suppose I get 3 more votes and aggregate rating becomes 4.8 out of 5 for 80 votes.

So how can I change the script here dynamically?

0

There are 0 answers