product-schema.liquid liquid
Copy {% comment %} Product JSON Schema - snippets/product-schema.liquid {% endcomment %}
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"image": [
{% for image in product.images limit: 5 %}
{{ image | img_url: 'grande' | prepend: 'https:' | json }}{% unless forloop.last %},{% endunless %}
{% endfor %}
],
"description": {{ product.description | strip_html | truncate: 300 | json }},
"sku": {{ product.selected_or_first_available_variant.sku | json }},
"brand": {
"@type": "Brand",
"name": {{ product.vendor | json }}
},
"offers": {
"@type": "Offer",
"url": {{ shop.url | append: product.url | json }},
"priceCurrency": {{ cart.currency.iso_code | json }},
"price": {{ product.selected_or_first_available_variant.price | divided_by: 100.0 | json }},
"priceValidUntil": "{{ 'now' | date: '%s' | plus: 31536000 | date: '%Y-%m-%d' }}",
"availability": "{% if product.selected_or_first_available_variant.available %}https://schema.org/InStock{% else %}https://schema.org/OutOfStock{% endif %}",
"itemCondition": "https://schema.org/NewCondition",
"seller": {
"@type": "Organization",
"name": {{ shop.name | json }}
}
}
{% if product.metafields.reviews.rating %}
,"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "{{ product.metafields.reviews.rating }}",
"reviewCount": "{{ product.metafields.reviews.count }}"
}
{% endif %}
}
</script>