Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I'm wondering if anyone can help me in order to fix my JSON script into the product.liquid.
Running some tests, data results are complete into the google merchant center, but not if I run a rich result test. In particular, I'm missing the following fields:
Herebelow I'm attaching my product.liquid
{% comment %}
The contents of the product.liquid template can be found in /sections/product-template.liquid
{% endcomment %}
{% section 'product-template' %}
{% section 'feature-columns-custom' %}
{% section 'product-recommendations' %}
{% if collection %}
<div class="text-center return-link-wrapper page-width">
<a href="{{ collection.url }}" class="btn btn--secondary btn--has-icon-before return-link">
{% include 'icon-arrow-left' %}
{{ 'products.product.back_to_collection' | t: title: collection.title }}
</a>
</div>
{% endif %}
<script>
// Override default values of shop.strings for each template.
// Alternate product templates can change values of
// add to cart button, sold out, and unavailable states here.
theme.productStrings = {
addToCart: {{ 'products.product.add_to_cart' | t | json }},
soldOut: {{ 'products.product.sold_out' | t | json }},
unavailable: {{ 'products.product.unavailable' | t | json }}
}
</script>
{% assign current_variant = product.selected_or_first_available_variant %}
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ shop.url | append: product.url | json }},
{%- if product.featured_media -%}
{%- assign media_size = product.featured_media.preview_image.width | append: 'x' -%}
"image": [
{{ product.featured_media | img_url: media_size | prepend: "https:" | json }}
],
{%- endif -%}
"description": {{ product.description | strip_html | json }},
{%- if current_variant.sku != blank -%}
"sku": {{ current_variant.sku | json }},
{%- endif -%}
"brand": {
"@type": "Brand",
"name": {{ product.vendor | json }}
},
"offers": [
{%- for variant in product.variants -%}
{
"@type" : "Offer",
{%- if variant.sku != blank -%}
"sku": {{ variant.sku | json }},
{%- endif -%}
"availability" : "http://schema.org/{% if product.available %}InStock{% else %}OutOfStock{% endif %}",
"price" : {{ variant.price | divided_by: 100.00 | json }},
"priceCurrency" : {{ cart.currency.iso_code | json }},
"url" : {{ shop.url | append: variant.url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
</script>
<!-- IORelatedProduct -->
<div id="io-related-prd-id" style="float: left; clear: both; width: 100%" data-id="{{product.id}}"></div>{{shop.metafields.grrelated_ns.grrelated_key}}
Here a link of a product if you want to run a test by yourselves https://www.pianodgirls.com/products/copia-di-tuta-palazzo-con-manica-fuxia-rinascimento?variant=394...
Any help for implement all the missing fields into the script?
Thanks in advance
The easiest way is to remove your existing code, and install the code shown in the tutorial here: https://feedarmy.com/kb/shopify-microdata-for-google-shopping/
@EmmanuelFlossiethanks for your reply
I tested and kinda works, but it returns some error you should fix in the script:
1) Reload the page, (Hard refresh) you might be seeing an old version, Brand was updated a few weeks ago. Latest version is 3.08
2) You can change the value by following the setting options, reference:
The following step requires you to check the product id in Google Merchant Center > Products > List. And see what ID you are using.
Let me know if you have any further questions, and happy to help.
We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024