2025-09-16 13:13:01 +08:00
|
|
|
{% comment %}
|
|
|
|
Renders Price on product grid item
|
|
|
|
|
|
|
|
Accepts:
|
|
|
|
- product: {Object} product (required)
|
|
|
|
- current_variabt: {Object} Current variant (required)
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
{% render 'product-grid-price', product: product, current_variant: current_variant %}
|
|
|
|
{% endcomment %}
|
|
|
|
|
|
|
|
{%- liquid
|
|
|
|
assign product_price_raw = product.price
|
|
|
|
assign product_price_min_raw = product.price_min
|
|
|
|
assign product_compare_at_price_raw = product.compare_at_price
|
|
|
|
|
|
|
|
assign product_price_raw = product.metafields.app--168074346497.min_auto_discounted_price.value | default: product.price
|
|
|
|
|
|
|
|
if product.metafields.app--168074346497.discount_percentage.value > 0.01
|
|
|
|
assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value
|
|
|
|
|
|
|
|
assign product_price_raw = product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
|
|
|
|
assign product_price_min_raw = product_price_raw
|
|
|
|
endif
|
|
|
|
|
|
|
|
if product_price_raw < product.price
|
|
|
|
assign product_compare_at_price_raw = product.price
|
|
|
|
|
|
|
|
if product.compare_at_price > product_compare_at_price_raw
|
|
|
|
assign product_compare_at_price_raw = product.compare_at_price
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if settings.currency_code_enable
|
|
|
|
assign product_price_min = product_price_min_raw | money_with_currency
|
|
|
|
assign product_compare_at_price = product_compare_at_price_raw | money_with_currency
|
|
|
|
else
|
|
|
|
assign product_price_min = product_price_min_raw | money
|
|
|
|
assign product_compare_at_price = product_compare_at_price_raw | money
|
|
|
|
endif
|
|
|
|
-%}
|
|
|
|
|
|
|
|
<span class="price{% if product_compare_at_price_raw > product_price_raw %} sale{% endif %}">
|
|
|
|
{% if product.available or badge_soldout != '' %}
|
|
|
|
<span class="new-price">
|
|
|
|
{% if product.price_varies %}
|
|
|
|
<small>{{ 'products.general.from' | t }}</small>
|
|
|
|
{% endif %}
|
|
|
|
{%- if product_price_raw == 0 and product.price_varies == false -%}
|
|
|
|
{{ 'general.money.free' | t }}
|
|
|
|
{%- else -%}
|
|
|
|
{{ product_price_min }}
|
|
|
|
{%- endif -%}
|
|
|
|
</span>
|
|
|
|
{% if product_compare_at_price_raw > product_price_raw %}
|
2025-10-08 05:28:31 +00:00
|
|
|
<span class="old-price">{{ product_compare_at_price }}</span>
|
2025-09-16 13:13:01 +08:00
|
|
|
{% endif %}
|
|
|
|
{% else %}
|
|
|
|
<span class="sold-out">{{ 'products.product.sold_out' | t }}</span>
|
|
|
|
{% endif %}
|
|
|
|
</span>
|
|
|
|
{% if current_variant.unit_price %}
|
|
|
|
{% capture unit_price_separator %}
|
|
|
|
<span aria-hidden="true">/</span>
|
|
|
|
<span class="visually-hidden">{{ 'general.accessibility.unit_price_separator' | t }} </span>
|
|
|
|
{% endcapture %}
|
|
|
|
{% capture unit_price_base_unit %}
|
|
|
|
{% if current_variant.unit_price_measurement.reference_value != 1 %}
|
|
|
|
{{ current_variant.unit_price_measurement.reference_value }}
|
|
|
|
{% endif %}
|
|
|
|
{{ current_variant.unit_price_measurement.reference_unit }}
|
|
|
|
{% endcapture %}
|
|
|
|
<br>
|
|
|
|
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.unit_price_label' | t }}</span>
|
|
|
|
<span class="unit small">{% if settings.currency_code_enable %}{{ current_variant.unit_price | money_with_currency }}{% else %}{{ current_variant.unit_price | money }}{% endif %}{{ unit_price_separator }}{{ unit_price_base_unit }}</span>
|
|
|
|
{% endif %}
|