Skip to content

Instantly share code, notes, and snippets.

Last active July 19, 2023 10:13
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Shopify product richsnippet - structured data markup for Shopify product templates
{% assign current_variant = product.selected_or_first_available_variant %}
<div id="richsnippet">
<div itemscope itemtype="">
<meta itemprop="url" content="{{ shop.url }}{{ product.url }}">
<meta itemprop="image" content="{{ product.featured_image.src | img_url: 'grande' }}">
<meta itemprop="name" content="{{ product.title | escape }}">
<meta itemprop="description" content="{{ product.description | strip_html }}">
{% if product.vendor %}<meta itemprop="brand" content="{{ product.vendor }}">{% endif %}
<div itemprop="offers" itemscope itemtype="">
<meta itemprop="priceCurrency" content="{{ shop.currency }}">
<meta itemprop="price" content="{{ current_variant.price | money_without_currency }}">
<link itemprop="availability" href="{% if product.available %}InStock{% else %}OutOfStock{% endif %}">
<meta itemprop="seller" content="{{ shop.domain }}">
<meta itemprop="itemcondition" itemtype="" content="" />
Copy link

toledox82 commented Apr 20, 2018

If the price is above 999, it will cause warning on testing tool, so need to add this string filter remove: ","

This line 14 will be:
<meta itemprop="price" content ="{{current_variant.price | money_without_currency | remove: ","}}">

Copy link

joe-dempsey commented May 1, 2018

product.first_available_variant and product.selected_or_first_available_variant will return the same for google bot - assign either.

I'd actually use a remove/replace function to format currencies which use a comma if google don't like that.

{{ current_variant.price | money_without_currency | remove: "." | replace: ',', '.' }}

most countries use the decimal - but easy to modify - this is just a guide

Copy link

joe-dempsey commented Nov 21, 2018

one addition is
<meta itemprop="itemcondition" itemtype="" content="" />

Copy link

rkvisai commented Jul 19, 2019

I'm still getting warnings for missing SKU

Copy link

Note the Google prefers JSON and not itemprop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment