Bookable Type
Displaying a Bookable's Type
{% for product in collection.products %}
{% assign current_variant = selected_or_first_available_variant %}
{% assign metafields = current_variant.metafields.bookings %}
{% if metafields != blank %} // Bookable Product
{{metafields.bookable_type}}
{% else %} // Not a bookable product
{{product.type}}
{% endif %}
{% endfor %}Accessing Metafields Based on a Bookable's Type
{% for product in collection.products %}
{% assign current_variant = selected_or_first_available_variant %}
{% assign metafields = current_variant.metafields.bookings %}
{% case metafields.bookable_type %}
{% when 'event' %}
<p>Start time: {{ metafield.starts_at }}</p>
<p>End time: {{ metafield.ends_at }}</p>
{% when 'course' %}
<p>Course Sessions:</p>
{% for session in metafields.sessions %}
<p>Start time: {{ session.starts_at }}</p>
<p>End time: {{ session.ends_at }}</p>
{% endfor %}
{% when 'service' %}
<p>{{ product.title }}</p>
<p>Start time: {{ metafield.starts_at }}</p>
<p>End time: {{ metafield.ends_at }}</p>
{% else %}
This product is not bookable
{% endcase %}
{% endfor %}Last updated
Was this helpful?