Files
Flex/snippets/product-thumbnail__product-info.liquid
T
2026-10-15 20:25:58 +08:00

101 lines
3.8 KiB
Plaintext

{% liquid
assign active_discount = true
assign empty_array = "" | split: ""
assign dormant_discounts = shop.metafields.app--168074346497.dormant_discounts.value | default: empty_array
assign target_discount_id = product.metafields.app--168074346497.applied_discount_id.value
for dormant_discount in dormant_discounts
if dormant_discount == target_discount_id
assign active_discount = false
endif
endfor
assign product_price = product.price
assign product_compare_at_price_max = product.compare_at_price_max
assign product_compare_at_price = product.compare_at_price
if active_discount
assign product_price = product.metafields.app--168074346497.min_auto_discounted_price.value | default: product.price
if product_price < product.price and product_compare_at_price == 0 or product_compare_at_price == blank
assign product_compare_at_price = product.price
endif
if product_price < product.price and product_compare_at_price_max == 0 or product_compare_at_price_max == blank
assign product_compare_at_price_max = product.price_max
endif
endif
%}
<div class="product-thumbnail">
{% if settings.display_vendor %}
<span class="product-thumbnail__vendor">{{ product.vendor }}</span>
{% endif %}
{% if hover_enabled %}
<span class="product-thumbnail__title">{{ product.title }}</span>
{% else %}
<a href="{{ product.url | within: collection }}" class="product-thumbnail__title">{{ product.title }}</a>
{% endif %}
{% if collection_handles contains 'coming-soon' %}
{% if settings.stickers_enabled == false %}
{{ 'collections.general.coming_soon' | t }}
{% endif %}
{% else %}
<span class="product-thumbnail__price price {% if product_compare_at_price_max > product_price %}sale{% endif %}">
{% if product.price_varies and product_price > 0 %}
<small><em>{{ 'products.general.from' | t }}</em></small>
{% endif %}
{% if product_price > 0 %}
<span class="money">
{%
render 'price-element',
price: product_price
%}
</span>
{% else %}
{{ settings.free_price_text }}
{% endif %}
{%- assign variant = product.selected_or_first_available_variant -%}
{% liquid
assign variant_price = variant.price
assign variant_compare_at_price = variant.compare_at_price
if active_discount
assign variant_price = variant.metafields.app--168074346497.auto_discounted_price.value | default: variant.price
assign variant_compare_at_price = variant.compare_at_price
if shop.metafields.app--168074346497.discount_percentage.value > 0.005
assign discount_percentage = shop.metafields.app--168074346497.discount_percentage.value | times: 1.0
assign deducted_percentage = 1.0 | minus: discount_percentage
assign variant_price = variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
endif
if variant_price < variant.price and variant_compare_at_price == 0 or variant_compare_at_price == blank
assign variant_compare_at_price = variant.price
endif
endif
%}
{% if variant_price < variant_compare_at_price %}
<span class="product-thumbnail__was-price compare-at-price">
<span class="money">
{%
render 'price-element',
price: variant_compare_at_price
%}
</span>
</span>
{% endif %}
</span>
{% if settings.select_first_available_variant %}
{%- assign variant_for_unit_price = product.variants | sort: 'price' | first -%}
{%
render 'unit-price',
item: variant_for_unit_price,
class: 'product-thumbnail__unit-price'
%}
{% endif %}
{% endif %}
</div>