Skip to content

Instantly share code, notes, and snippets.

@akopcz2
Created July 18, 2019 03:13
Show Gist options
  • Save akopcz2/7e252243cde6c2b8b0eec2221f4f61e1 to your computer and use it in GitHub Desktop.
Save akopcz2/7e252243cde6c2b8b0eec2221f4f61e1 to your computer and use it in GitHub Desktop.
Shopify Json LD
<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