{%- comment -%}
----------------------------------------------------------------------------------------------------------------------
PRODUCT BADGES COMPONENT
----------------------------------------------------------------------------------------------------------------------
This component is used in product listing and product page to render the badges of a given product
********************************************
Supported variables
********************************************
* product: the product to render the badges
* variant: the specific variant to show the badge from
* types: the types of badge to output. Can be "custom", "sold_out" or "discount" (or a combination separated by comma). If nothing is set, all badges are outputted.
* class: an extra class added on the container
{%- endcomment -%}
{%- assign badge_types = types | default: 'custom, sold_out, discount' | split: ',' -%}
{%- assign variant = variant | default: product.selected_or_first_available_variant -%}
{%- capture badges -%}
{%- for badge_type in badge_types -%}
{%- assign stripped_badge_type = badge_type | strip -%}
{%- case stripped_badge_type -%}
{%- when 'custom' -%}
{%- assign custom_badges = product.metafields.custom.badges.value | sort -%}
{%- for custom_badge in custom_badges -%}
{{ custom_badge }}
{%- endfor -%}
{%- when 'sold_out' -%}
{%- if settings.show_sold_out_badge -%}
{%- if variant.available == false -%}