Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate featured product template to use structured data filter #3507

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 1 addition & 42 deletions sections/featured-product.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,11 @@
render 'share-button', block: block, share_link: share_url
%}
{%- when 'variant_picker' -%}
{% render 'product-variant-picker',
product: product,
block: block,
product_form_id: product_form_id
%}

Check warning on line 372 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L368-L372

[NestedSnippet] Too many nested snippets

Check warning on line 372 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L368-L372

[NestedSnippet] Too many nested snippets

Check warning on line 372 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L368-L372

[NestedSnippet] Too many nested snippets
{%- when 'buy_buttons' -%}
{%- render 'buy-buttons',
block: block,
Expand Down Expand Up @@ -458,53 +458,12 @@
if product.selected_or_first_available_variant.featured_media
assign seo_media = product.selected_or_first_available_variant.featured_media
else
assign seo_media = product.featured_media

Check warning on line 461 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L461

[UnusedAssign] `seo_media` is never used
endif
-%}

<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ request.origin | append: product.url | json }},
{% if seo_media -%}
"image": [
{{ seo_media | image_url: width: 1920 | prepend: "https:" | json }}
],
{%- endif %}
"description": {{ product.description | strip_html | json }},
{% if product.selected_or_first_available_variant.sku != blank -%}
"sku": {{ product.selected_or_first_available_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 -%}
{%- if variant.barcode.size == 12 -%}
"gtin12": {{ variant.barcode | json }},
{%- endif -%}
{%- if variant.barcode.size == 13 -%}
"gtin13": {{ variant.barcode | json }},
{%- endif -%}
{%- if variant.barcode.size == 14 -%}
"gtin14": {{ variant.barcode | json }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"price" : {{ variant.price | divided_by: 100.00 | json }},
"priceCurrency" : {{ cart.currency.iso_code | json }},
"url" : {{ request.origin | append: variant.url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
{{ product | structured_data }}
</script>

{% if product.media.size > 0 %}
Expand All @@ -513,7 +472,7 @@
{% endif %}
</product-info>

{% schema %}

Check notice on line 475 in sections/featured-product.liquid

View workflow job for this annotation

GitHub Actions / Theme Check Report

sections/featured-product.liquid#L475

[SchemaJsonFormat] JSON formatting could be improved
{
"name": "t:sections.featured-product.name",
"tag": "section",
Expand Down
Loading