Modify JSON LD / structured data

It appears that last year Shopify has introduced a filter to create the JSON-LD.
{{ product | structured_data }}
However, this is fixed and not flexible. I need to modify the price as we have a minimum order quantity, everything else should remain as is.

Does someone have the liquid code to generate the JSON-LD so that I don’t have to start from scratch?

Maybe Shopify could document the necessary code or make it possible to adjust values while keeping the rest.

Can get the implementation from an older version of Dawn:

Hi,

Hope this will help

  • Shopify’s default {{ product | structured_data }} is not editable.So we write our own JSON-LD using Liquid code.

JSON-LD example

<script type="application/ld+json">
{
  "@context": "https://schema.org/",
  "@type": "Product",
  "name": "{{ product.title | escape }}",
  "image": [
    {% for image in product.images %}
      "{{ image | img_url: 'master' }}"{% unless forloop.last %},{% endunless %}
    {% endfor %}
  ],
  "description": "{{ product.description | strip_html | escape }}",
  "sku": "{{ product.sku }}",
  "brand": {
    "@type": "Brand",
    "name": "{{ product.vendor }}"
  },
  "offers": {
    "@type": "Offer",
    "url": "{{ product.url | shop_url }}",
    "priceCurrency": "{{ shop.currency }}",
    "price": "{{ product.price | divided_by: 100.0 | times: 5 }}",
    "priceValidUntil": "2025-12-31",
    "availability": "https://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
    "itemCondition": "https://schema.org/NewCondition"
  }
}
</script>

Thank you, that helped :slight_smile:

@kadajawi I can share one JSON-LD example below for your reference:

 <html>
  <head>
    <title>Executive Anvil</title>
    <script type="application/ld+json">
    {
      "@context": "https://schema.org/",
      "@type": "Product",
      "name": "Executive Anvil",
      "image": [
        "https://example.com/photos/1x1/photo.jpg",
        "https://example.com/photos/4x3/photo.jpg",
        "https://example.com/photos/16x9/photo.jpg"
       ],
      "description": "Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.",
      "sku": "0446310786",
      "mpn": "925872",
      "brand": {
        "@type": "Brand",
        "name": "ACME"
      },
      "review": {
        "@type": "Review",
        "reviewRating": {
          "@type": "Rating",
          "ratingValue": 4,
          "bestRating": 5
        },
        "author": {
          "@type": "Person",
          "name": "Fred Benson"
        }
      },
      "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": 4.4,
        "reviewCount": 89
      },
      "offers": {
        "@type": "Offer",
        "url": "https://example.com/anvil",
        "priceCurrency": "USD",
        "price": 119.99,
        "priceValidUntil": "2024-11-20",
        "itemCondition": "https://schema.org/UsedCondition",
        "availability": "https://schema.org/InStock"
      }
    }
    </script>
  </head>
  <body>
  </body>
</html>

Actually, there exist one category listing the ways of adjusting values and modifying price in multiple ways in Google Developer Doc. You can read this article here I attach below for more details and I believe one of them is what you need.
Merchant listing (Product, Offer) structured data