Files
Habitat/snippets/product-card-badge.liquid
T

24 lines
1.2 KiB
Plaintext
Raw Normal View History

2026-06-25 16:17:40 +08:00
{%- assign badge_position = settings.badge_position -%}
{% liquid
assign product_card_product_price = product_card_product.price
assign product_card_product_compare_at_price = product_card_product.compare_at_price
assign product_card_product_price = product_card_product.metafields.app--168074346497.min_auto_discounted_price.value | default: product_card_product.price
if product_card_product_price < product_card_product.price and product_card_product_compare_at_price == 0 or product_card_product_compare_at_price == blank
assign product_card_product_compare_at_price = product_card_product.price
endif
%}
{%- unless product_card_product.available -%}
<span class="badge out-of-stock {{ badge_position }}">{{ 'products.product.sold_out' | t }}</span>
{%- endunless -%}
{%- if product_card_product_compare_at_price > product_card_product_price and product_card_product.available -%}
<span class="badge onsale {{ badge_position }}">{{ 'products.product.on_sale' | t }}</span>
{%- endif -%}
{%- if product_card_product.metafields.theme.preorder and product_card_product.available -%}
<span class="badge pre-order {{ badge_position }}">
{{ 'products.product.pre_order' | t }}
</span>
{%- endif -%}