Shopify 多规格 ProductGroup 与退货运费 Liquid 代码生成器
许多旧版 Shopify 主题在结构化数据里只输出最低价变体,或缺少 MerchantReturnPolicy 与 OfferShippingDetails 字段。填写你的真实运费与退货规则,生成可直接放入主题 snippets 目录的 .liquid 代码块。
纯浏览器端实时生成 · 无需登录 · 复制或下载代码不设任何门槛
运费标准与时效(USD)
备货天数(最快–最慢)
–
运输天数(最快–最慢)
–
退货政策(MerchantReturnPolicy)
生成的 Shopify Liquid 代码片段
snippets/storepolicycheck-gmc-schema.liquid
{% comment %}
StorePolicyCheck — Google Merchant Center Next (2026) ProductGroup + Return & Shipping Schema Patch
Target Market: US (USD) | Domain: yourstore.com
Installation:
1. Shopify Admin -> Online Store -> Themes -> "..." -> Edit code
2. Under "Snippets", create "storepolicycheck-gmc-schema.liquid" and paste this entire file.
3. Open "layout/theme.liquid", paste {% render 'storepolicycheck-gmc-schema' %} right above </head>, and Save.
{% endcomment %}
{% if request.page_type == 'product' and product %}
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "ProductGroup",
"@id": "{{ shop.url }}{{ product.url }}#product-group",
"name": {{ product.title | json }},
"description": {{ product.description | strip_html | truncatewords: 120 | json }},
"url": "{{ shop.url }}{{ product.url }}",
"productGroupID": "{{ product.id }}",
"brand": {
"@type": "Brand",
"name": {{ product.vendor | default: shop.name | json }}
}{% if product.featured_image %},
"image": "https:{{ product.featured_image | image_url: width: 1500 }}"{% endif %},
"hasMerchantReturnPolicy": {
"@type": "MerchantReturnPolicy",
"applicableCountry": "US",
"returnPolicyCategory": "https://schema.org/MerchantReturnFiniteReturnWindow",
"merchantReturnDays": 30,
"returnMethod": "https://schema.org/ReturnByMail",
"returnFees": "https://schema.org/ReturnFeesCustomerResponsibility"
},
"hasVariant": [
{% for variant in product.variants %}
{% assign variant_price_major = variant.price | divided_by: 100.0 %}
{% assign clean_barcode = variant.barcode | strip %}
{% assign barcode_len = clean_barcode | size %}
{
"@type": "Product",
"@id": "{{ shop.url }}{{ product.url }}?variant={{ variant.id }}#variant",
"name": {{ product.title | append: ' - ' | append: variant.title | json }},
"sku": {{ variant.sku | default: variant.id | json }}{% if barcode_len == 8 or barcode_len == 12 or barcode_len == 13 or barcode_len == 14 %},
"gtin": {{ clean_barcode | json }}{% endif %}{% if variant.featured_image %},
"image": "https:{{ variant.featured_image | image_url: width: 1500 }}"{% elsif product.featured_image %},
"image": "https:{{ product.featured_image | image_url: width: 1500 }}"{% endif %},
"offers": {
"@type": "Offer",
"url": "{{ shop.url }}{{ product.url }}?variant={{ variant.id }}",
"price": "{{ variant.price | divided_by: 100.0 }}",
"priceCurrency": {{ cart.currency.iso_code | json }},
"availability": "https://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"itemCondition": "https://schema.org/NewCondition",
"shippingDetails": {
"@type": "OfferShippingDetails",
"shippingRate": {
"@type": "MonetaryAmount",
"value": "{% if variant_price_major >= 50 %}0.00{% else %}6.95{% endif %}",
"currency": {{ cart.currency.iso_code | json }}
},
"shippingDestination": {
"@type": "DefinedRegion",
"addressCountry": "US"
},
"deliveryTime": {
"@type": "ShippingDeliveryTime",
"handlingTime": {
"@type": "QuantitativeValue",
"minValue": 1,
"maxValue": 2,
"unitCode": "DAY"
},
"transitTime": {
"@type": "QuantitativeValue",
"minValue": 3,
"maxValue": 7,
"unitCode": "DAY"
}
}
}
}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
</script>
{% endif %}这个工具做不到什么(检查边界)
- 将代码粘贴进主题后,若旧主题或第三方 SEO 插件仍在同一页面输出冲突的 Product JSON-LD,需注释掉旧的重复代码块。
- 结构化代码必须与你公开的《运费政策》《退货政策》页面文字以及 Google Merchant Center 后台设置完全一致,切勿只改代码不改页面。
常见问题
生成的 .liquid 文件放在 Shopify 主题哪个位置?
在 Shopify 后台打开 Online Store → Themes → Edit code,先在操作前复制备份当前主题,然后在 snippets/ 下新建 storepolicycheck-gmc-schema.liquid 粘贴代码,并在主商品模板里用 {% render 'storepolicycheck-gmc-schema' %} 引入。