{% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}
{% set event = null %}
{% if page.product %}
{% set eventmain = page.product.extension('event') %}
{% set eventparent = page.product.extension('eventparent') %}
{% if(eventmain) %}
{% set event = eventmain %}
{% else %}
{% set event = eventparent %}
{% endif %}
{% endif %}
{% block layout_head_meta_tags_schema_webpage %}
{{ parent() }}
{% block events_meta %}
{% if event and event.bookable and event.slots|length > 0 %}
{% set timeZone = event.timezone ?? 'UTC' %}
<script type="application/ld+json">
[
{% for slot in event.slots %}
{
"@context": "https://schema.org",
"@type": "Event",
"name": "{{ event.title }}",
"description": "{{ event.description }}",
"startDate": "{{ slot.from|date('Y-m-d', timezone=timeZone) }}T{{ slot.from|date('H:i', timezone=timeZone) }}",
"endDate": "{{ slot.until|date('Y-m-d', timezone=timeZone) }}T{{ slot.until|date('H:i', timezone=timeZone) }}",
"location" : {
"name": "{{ slot.location }}",
"address" : "{{ slot.address }}"
}
}{% if not loop.last %},{% endif %}
{% endfor %}
]
</script>
{% endif %}
{% endblock %}
{% endblock %}