product card badge

This commit is contained in:
Axel
2026-06-25 16:17:40 +08:00
parent a5a4c7befb
commit 9c1226fa86
2 changed files with 23 additions and 0 deletions
Vendored
BIN
View File
Binary file not shown.
+23
View File
@@ -0,0 +1,23 @@
{%- 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 -%}