{% for badge in ordered_badges %}
{% unless product.tags contains badge.tag %}
{% continue %}
{% endunless %}
{% assign inclusions = badge.collection_inclusion | default: '' | strip | split: ',' %}
{% assign exclusions = badge.collection_exclusion | default: '' | strip | split: ',' %}
{% assign should_render = true %}
{% if inclusions != blank %}
{% assign should_render = false %}
{% for inclusion in inclusions %}
{% assign trimmed_inclusion = inclusion | strip %}
{% if trimmed_inclusion == collection_handle %}
{% assign should_render = true %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% if exclusions != blank %}
{% for exclusion in exclusions %}
{% assign trimmed_exclusion = exclusion | strip %}
{% if trimmed_exclusion == collection_handle %}
{% assign should_render = false %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% unless should_render %}
{% continue %}
{% endunless %}
{% assign badge_position = badge.position | handle %}
{% assign badge_tag_downcase = badge.tag | downcase %}
{% if badge_tag_downcase == 'sale' %}
{% if discount_percentage < 10 %}
{% continue %}
{% endif %}
{% endif %}
{% if position == 'top' %}
{% if badge_position != 'top' %}
{% continue %}
{% endif %}
{% elsif position == 'bottom' %}
{% if badge_position != 'bottom' %}
{% continue %}
{% endif %}
{% endif %}
{% if badge_limit > 0 %}
{% if badge_count >= badge_limit %}
{% continue %}
{% endif %}
{% endif %}
{% assign text = badge.text %}
{% assign badge_tag_downcase = badge.tag | downcase %}
{% if badge_tag_downcase == 'sale' %}
{% assign dynamic_discount = discount_percentage | append: '%' %}
{% if text == blank %}
{% assign text = dynamic_discount | append: ' OFF' %}
{% else %}
{% assign text = text | replace: 'XX%', dynamic_discount | replace: 'XX', discount_percentage %}
{% endif %}
{% endif %}
{% if badge.image != blank %}
{% elsif badge.icon != blank %}
{% elsif badge.emoji != blank %}
{% endif %}
{{ text }}
{% assign badge_count = badge_count | plus: 1 %}
{% endfor %}
{{ title }}
{{ subtitle }}
{{ price }}
{% assign discount_percentage = product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round %} {% assign product_price = product.price | plus: 0 %} {% if product.compare_at_price > product_price and discount_percentage >= 10 %}
{% for badge in ordered_badges %}
{% unless product.tags contains badge.tag %}
{% continue %}
{% endunless %}
{% assign inclusions = badge.collection_inclusion | default: '' | strip | split: ',' %}
{% assign exclusions = badge.collection_exclusion | default: '' | strip | split: ',' %}
{% assign should_render = true %}
{% if inclusions != blank %}
{% assign should_render = false %}
{% for inclusion in inclusions %}
{% assign trimmed_inclusion = inclusion | strip %}
{% if trimmed_inclusion == collection_handle %}
{% assign should_render = true %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% if exclusions != blank %}
{% for exclusion in exclusions %}
{% assign trimmed_exclusion = exclusion | strip %}
{% if trimmed_exclusion == collection_handle %}
{% assign should_render = false %}
{% break %}
{% endif %}
{% endfor %}
{% endif %}
{% unless should_render %}
{% continue %}
{% endunless %}
{% assign badge_position = badge.position | handle %}
{% assign badge_tag_downcase = badge.tag | downcase %}
{% if badge_tag_downcase == 'sale' %}
{% if discount_percentage < 10 %}
{% continue %}
{% endif %}
{% endif %}
{% if position == 'top' %}
{% if badge_position != 'top' %}
{% continue %}
{% endif %}
{% elsif position == 'bottom' %}
{% if badge_position != 'bottom' %}
{% continue %}
{% endif %}
{% endif %}
{% if badge_limit > 0 %}
{% if badge_count >= badge_limit %}
{% continue %}
{% endif %}
{% endif %}
{% assign text = badge.text %}
{% assign badge_tag_downcase = badge.tag | downcase %}
{% if badge_tag_downcase == 'sale' %}
{% assign dynamic_discount = discount_percentage | append: '%' %}
{% if text == blank %}
{% assign text = dynamic_discount | append: ' OFF' %}
{% else %}
{% assign text = text | replace: 'XX%', dynamic_discount | replace: 'XX', discount_percentage %}
{% endif %}
{% endif %}
{% if badge.image != blank %}
{% elsif badge.icon != blank %}
{% elsif badge.emoji != blank %}
{% endif %}
{{ text }}
{% assign badge_count = badge_count | plus: 1 %}
{% endfor %}
{% endif %}
{% endfor %}