{% comment %} Renders a list of product's price (regular, sale) Accepts: - product_ref: {Object} Product Liquid object - use_variant: {Boolean} Renders selected or first variant price instead of overall product pricing (optional) - price_class: {String} Adds a price class to the price element (optional) - price_extra_info: {Boolean} Show extra info about price (optional) Usage: {% render 'price', product_ref: product %} {% endcomment %} {%- liquid if use_variant assign target = product_ref.selected_or_first_available_variant else assign target = product_ref endif assign variant = product_ref.selected_or_first_available_variant assign compare_at_price = target.compare_at_price assign price = target.price | default: 1999 if target == product_ref and product_ref.price_varies == false assign compare_at_price = target.compare_at_price_max endif if use_variant assign price = target.metafields.app--168074346497.auto_discounted_price.value | default: target.price if target.metafields.app--168074346497.discount_type.value != nil and target.metafields.app--168074346497.discount_type.value != "fixed" and product_ref.metafields.app--168074346497.discount_percentage.value > 0.01 assign deducted_percentage = 1.0 | minus: product_ref.metafields.app--168074346497.discount_percentage.value if target.metafields.app--168074346497.discount_percentage.value > 0.01 assign deducted_percentage = 1.0 | minus: target.metafields.app--168074346497.discount_percentage.value endif assign price = target.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign compare_at_price = target.price if target.compare_at_price > compare_at_price assign compare_at_price = target.compare_at_price endif endif 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 price = target.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign compare_at_price = target.price if target.compare_at_price > compare_at_price assign compare_at_price = target.compare_at_price endif endif if price < target.price and compare_at_price == blank assign compare_at_price = target.price endif else assign price = product_ref.metafields.app--168074346497.min_auto_discounted_price.value | default: product_ref.price if product_ref.metafields.app--168074346497.discount_percentage.value > 0.01 assign deducted_percentage = 1.0 | minus: product_ref.metafields.app--168074346497.discount_percentage.value assign price = product_ref.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign compare_at_price = product_ref.price if product_ref.compare_at_price > compare_at_price assign compare_at_price = product_ref.compare_at_price endif endif 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 price = product_ref.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign compare_at_price = product_ref.price if product_ref.compare_at_price > compare_at_price assign compare_at_price = product_ref.compare_at_price endif endif if price < product_ref.price and compare_at_price == blank assign compare_at_price = product_ref.price endif endif assign available = target.available | default: false assign money_price = price | money assign price_extra_info = price_extra_info | default: false if settings.show_currency_codes assign money_price = price | money_with_currency endif -%}
{%- if product_ref -%} {%- if target == product_ref and product_ref.price_varies -%} {%- liquid assign money_price_min = product_ref.price_min assign money_price_max = product_ref.price_max assign compare_at_price_max = product_ref.compare_at_price_max if compare_at_price < price assign min_price_class = 'class="sale"' assign money_price_min = product_ref.compare_at_price_min endif -%} {%- if compare_at_price_max > money_price_max -%} {%- assign sale_container_class = 'price__sale' -%} {%- if show_sale_badge -%} {%- assign sale_container_class = sale_container_class | append: ' price__sale--has-badge' -%} {%- capture sale_text_html -%} {{- 'products.product.price.sale_badge' | t -}} {%- endcapture -%} {%- endif -%}
{{- 'products.product.price.regular_price' | t -}} {{- compare_at_price_max | money -}} {{- 'products.product.price.from_price' | t -}} {{- 'products.product.price.min_price' | t -}} {{- money_price_min | money -}} {{- 'products.product.price.max_price' | t -}} {{- money_price_max | money -}}
{{ sale_text_html }}
{% else %}
{{- 'products.product.price.min_price' | t -}} {{- product_ref.price_min | money -}} {{- 'products.product.price.max_price' | t -}} {{- product_ref.price_max | money -}}
{%- endif -%} {%- elsif compare_at_price > price -%} {%- assign sale_container_class = 'price__sale' -%} {%- if show_sale_badge -%} {%- assign sale_container_class = sale_container_class | append: ' price__sale--has-badge' -%} {%- capture sale_text_html -%} {{- 'products.product.price.sale_badge' | t -}} {%- endcapture -%} {%- endif -%}
{{- 'products.product.price.regular_price' | t -}} {{- compare_at_price | money -}} {{- 'products.product.price.sale_price' | t -}} {{- money_price -}}
{{ sale_text_html }}
{%- else -%}
{{- 'products.product.price.regular_price' | t -}} {{- money_price -}}
{%- endif -%} {%- if variant.unit_price_measurement -%}
{{- 'products.product.price.unit_price' | t -}} {%- if settings.show_currency_codes -%} {{- variant.unit_price | money_with_currency -}} {%- else -%} {{- variant.unit_price | money -}} {%- endif -%} {%- if variant.unit_price_measurement.reference_value != 1 -%} {{- variant.unit_price_measurement.reference_value -}} {%- endif -%} {{- variant.unit_price_measurement.reference_unit -}}
{%- endif -%} {%- if price_extra_info and cart.taxes_included or shop.shipping_policy.body != blank -%}
{% liquid assign taxes_text = '' if cart.taxes_included assign taxes_text = 'products.product.include_taxes' | t | append: ' ' endif if shop.shipping_policy.body != blank assign shipping_text = 'products.product.shipping_policy_html' | t: link: shop.shipping_policy.url assign taxes_text = taxes_text | append: shipping_text endif %} {{- taxes_text -}}
{%- endif -%} {%- else -%} {{- 9999 | money -}} {%- endif -%}