Created
July 18, 2019 03:13
-
-
Save akopcz2/7e252243cde6c2b8b0eec2221f4f61e1 to your computer and use it in GitHub Desktop.
Shopify Json LD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org/", | |
"@type": "Product", | |
"name": "{{ product.title | strip_html | escape }}", | |
"url": "{{ shop.url }}{{ product.url }}", | |
{% if current_variant.sku != blank %} | |
"sku": "{{ current_variant.sku }}", | |
{% endif %} | |
"brand": { | |
"@type": "Thing", | |
"name": "{{ product.vendor | escape }}" | |
}, | |
"description": "{{ product.description | strip_html | escape }}", | |
"image": "https:{{ product.featured_image.src | img_url: 'grande' }}", | |
"sku": "{{variant.sku}}", | |
{% if product.metafields.yotpo.reviews_count and product.metafields.yotpo.reviews_count != "0" %} | |
"aggregateRating":"{{product.metafields.yotpo.reviews_average}}", | |
"review": "{{product.metafields.yotpo.reviews_count}}", | |
{% endif %} | |
{% if product.variants %} | |
"offers": [ | |
{% for variant in product.variants %} | |
{ | |
"@type" : "Offer", | |
"priceCurrency": "{{ shop.currency }}", | |
"price": "{{ variant.price | money_without_currency | remove: "," }}", | |
"itemCondition" : "http://schema.org/NewCondition", | |
"availability" : "http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}", | |
"url" : "{{ shop.url }}{{ variant.url }}", | |
"itemOffered" : | |
{ | |
"@type" : "Product", | |
{% if variant.image %} | |
{% assign variant_image_size = variant.image.width | append: 'x' %} | |
"image": "http:{{ variant.image.src | img_url: variant_image_size }}", | |
{% endif %} | |
{% if variant.title != blank %} | |
"name" : "{{ variant.title | escape }}", | |
{% endif %} | |
{% if variant.sku != blank %} | |
"sku": "{{ variant.sku }}", | |
{% endif %} | |
{% if variant.weight != blank %} | |
"weight": { | |
"@type": "QuantitativeValue", | |
{% if variant.weight_unit != blank %} | |
"unitCode": "{{ variant.weight_unit }}", | |
{% endif %} | |
"value": "{{ variant.weight | weight_with_unit: variant.weight_unit }}" | |
}, | |
{% endif %} | |
"url": "{{ shop.url }}{{ variant.url }}" | |
} | |
}{% unless forloop.last %},{% endunless %} | |
{% endfor %} | |
] | |
{% endif %} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment