My goal is to conditionally show sale prices on my website, and communicate this information to Google Merchant Center so when a sale is running, they will show the current sale price, and the original compare at price. Is this formatted correctly to pass this information to Google in this way?
{% if SaleActive == true %}
"offers": {
"@type": "Offer",
"priceCurrency": {{ cart.currency.iso_code | json }},
"price": {{ selected_variant.price | times: SaleMultiplier | divided_by: 100.0 | json }},
"availability": "http://schema.org/{% if selected_variant.available %}InStock{% else %}OutOfStock{% endif %}",
"url": "{{ shop.url }}{{ selected_variant.url }}",
"seller": {
"@type": "Organization",
"name": {{ shop.name | json }}
},
"priceValidUntil": "{{ SaleEndingDatetimeConverted }}",
"priceSpecification": {
"@type": "PriceSpecification",
"price": {{ selected_variant.price | divided_by: 100.0 | json }},
"priceCurrency": {{ cart.currency.iso_code | json }}
}
}
{% elsif SaleActive == false %}
"offers": {
"@type": "Offer",
"priceCurrency": {{ cart.currency.iso_code | json }},
"price": {{ selected_variant.price | divided_by: 100.0 | json }},
"availability": "http://schema.org/{% if selected_variant.available %}InStock{% else %}OutOfStock{% endif %}",
"url": "{{ shop.url }}{{ selected_variant.url }}",
"seller": {
"@type": "Organization",
"name": {{ shop.name | json }}
},
"priceValidUntil": {{ year_from_now | json }}
}
{% endif %}
My concern is, neither price in the SaleActive == true block is explicitly specified as "current price" or "compare at price". So I'm just wondering, will Google be able to parse this and understand which price is which, and understand that it's meant to show one as the current sale price, the other as the comparison price?
FYI this code is in the products__structured-data.liquid file of my Shopify website. I have the Google shopping channel app which automatically creates a Merchant Center Feed based on the active products on my Shopify Store.
Thanks