Микроразметка ld+json для Shop-Script
Вставьте данный код в файл product.html
{foreach $product.skus as $min}
{$minmax[] = $min.price}
{/foreach}
{$reviews_count = count($reviews)}
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{$product.name|escape}",
"image": "{$img}",
"description": "{$product.summary|escape}",
{if $sku.sku}
"sku": "{$sku.sku|escape}",
{/if}
{if $product.sku_type}
{$default_sku_features = $product.sku_features}
{$product_available = $product.status}
"offers": {
"@type": "AggregateOffer",
"priceCurrency": "{$product.currency}",
"offerCount": "{count($product.skus)}",
"lowPrice": "{min($minmax)}",
"highPrice": "{max($minmax)}",
"offers": [
{foreach $product.skus as $sku}
{
"@type": "Offer",
"url": "{$wa->currentUrl(true, true)}?sku={$sku.id}",
"priceCurrency": "{$product.currency}",
"price": "{$sku.price}",
"priceValidUntil": "2030-06-08",
{$sku_available = $product.status && $sku.available && ($wa->shop->settings('ignore_stock_count') || $sku.count === null || $sku.count > 0)}
{if $sku.name}
"name": "{$sku.name|escape}",
{/if}
"sku": "{$sku.id}",
{if (!($sku.count === null) && $sku.count <= 0)}
"availability": "https://schema.org/OutOfStock",
{else}
"availability": "https://schema.org/InStock",
{/if}
"itemCondition": "https://schema.org/NewCondition"
}{if !$sku@last},{/if}
{/foreach}
]}{if $reviews_count > 0},{/if}
{else}
{$product_available = false}
{if count($product.skus) > 1}
"offers": {
"@type": "AggregateOffer",
"priceCurrency": "{$product.currency}",
"offerCount": "{count($product.skus)}",
"lowPrice": "{min($minmax)}",
"highPrice": "{max($minmax)}",
"offers": [
{foreach $product.skus as $sku}
{$sku_available = $product.status && $sku.available && ($wa->shop->settings('ignore_stock_count') || $sku.count === null || $sku.count > 0)}
{
"@type": "Offer",
"url": "{$wa->currentUrl(true, true)}?sku={$sku.id}",
"priceValidUntil": "2030-06-08",
{$sku_available = $product.status && $sku.available && ($wa->shop->settings('ignore_stock_count') || $sku.count === null || $sku.count > 0)}
"sku": "{$sku.id}",
{if $sku.name}
"name": "{$sku.name|escape}",
{/if}
"price": "{$sku.price}",
{if (!($sku.count === null) && $sku.count <= 0)}
"availability": "https://schema.org/OutOfStock",
{else}
"availability": "https://schema.org/InStock",
{/if}
"itemCondition": "https://schema.org/NewCondition"
}{if !$sku@last},{/if}
{$product_available = $product_available or $sku_available}
{/foreach}
]}{if $reviews_count > 0},{/if}
{else}
"offers": {
"@type": "Offer",
"url": "{$wa->currentUrl(true, true)}",
"priceValidUntil": "2030-06-08",
{$sku = $product.skus[$product.sku_id]}
{if $sku.name}
"name": "{$sku.name|escape}",
{/if}
"price": "{$sku.price}",
"priceCurrency": "{$product.currency}",
{if !$sku.available}
"availability": "https://schema.org/Discontinued",
{elseif !$wa->shop->settings('ignore_stock_count') && !($sku.count === null || $sku.count > 0)}
"availability": "https://schema.org/OutOfStock",
{else}
"availability": "https://schema.org/InStock",
{/if}
"itemCondition": "https://schema.org/NewCondition"
}{if $reviews_count > 0},{/if}
{/if}
{/if}
{if $reviews_count > 0}
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "{$product.rating|round:1}",
"bestRating": "5",
"worstRating": "0",
"ratingCount": "{$reviews_count}"
}
{/if}
}
</script>
Смотрите также
26 июля 2024
10 июня 2024
26 октября 2023
7 июля 2023
31 октября 2022
22 марта 2022
1 апреля 2021
2 февраля 2021
18 ноября 2020