{%- comment -%} ---------------------------------------------------------------------------------------------------------------------- PRODUCT PRICE ---------------------------------------------------------------------------------------------------------------------- This component generates price list for a given product. It handles the rendering of both price, compare at price, sale price and unit price ******************************************** Supported variables ******************************************** * product: the product from which prices are rendered * variant: if a variant is specified, then only the price from this variant is rendered (used in product details) * line_item: if a line item is specified, then the price from this line item are rendered * hide_unit_price: if set to true, unit pricing are hidden (this is useful for elements that are very size constrained) * size: can be either "sm" or "lg". If none is passed it will use the standard size * alignment: can be "center" to align the prices {%- endcomment -%} {%- liquid case size when 'lg' assign regular_price_classes = 'text-lg' assign on_sale_price_classes = 'text-lg text-on-sale' assign compare_at_price_classes = 'text-subdued line-through' assign unit_price_classes = 'text-subdued' when 'sm' assign regular_price_classes = 'text-subdued text-sm' assign on_sale_price_classes = 'text-on-sale text-sm' assign compare_at_price_classes = 'text-subdued text-sm line-through' assign unit_price_classes = 'text-subdued text-sm' else assign regular_price_classes = 'text-subdued' assign on_sale_price_classes = 'text-on-sale' assign compare_at_price_classes = 'text-subdued line-through' assign unit_price_classes = 'text-subdued text-sm' endcase -%} {%- liquid assign product_price = product.price assign product_price_min = product.price_min assign product_price_max = product.price_max assign product_compare_at_price = product.compare_at_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 = product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign product_price_min = product_price assign product_price_max = product.price_max | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign product_compare_at_price = product.price if product.compare_at_price > product_compare_at_price assign product_compare_at_price = product.compare_at_price endif elsif product.metafields.app--168074346497.min_auto_discounted_price.value > 0.01 assign product_price = product.metafields.app--168074346497.min_auto_discounted_price.value assign product_price_min = product_price assign product_compare_at_price = product.price if product.compare_at_price > product_compare_at_price assign product_compare_at_price = product.compare_at_price endif endif -%} {%- if variant != blank -%} {%- liquid assign variant_price = variant.price assign variant_compare_at_price = variant.price if variant.metafields.app--168074346497.discount_type.value != nil and variant.metafields.app--168074346497.discount_type.value != "fixed" and product.metafields.app--168074346497.discount_percentage.value > 0.01 assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value if variant.metafields.app--168074346497.discount_percentage.value > 0.01 assign deducted_percentage = 1.0 | minus: variant.metafields.app--168074346497.discount_percentage.value endif assign variant_price = variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign variant_compare_at_price = variant.price if variant.compare_at_price > variant_compare_at_price assign variant_compare_at_price = variant.compare_at_price endif elsif variant.metafields.app--168074346497.discount_type.value == "fixed" assign variant_price = variant.metafields.app--168074346497.auto_discounted_price.value assign variant_compare_at_price = variant.price if variant.compare_at_price > variant_compare_at_price assign variant_compare_at_price = variant.compare_at_price endif endif -%} {%- comment -%} -------------------------------------------------------------------------------------------------------------------- VARIANT CASE (used on product page, quick view...) -------------------------------------------------------------------------------------------------------------------- {%- endcomment -%} {{ 'product.price.sale_price' | t }} {%- if settings.currency_code_enabled -%} {{- variant_price | money_with_currency -}} {%- else -%} {{- variant_price | money -}} {%- endif -%} {%- if variant_compare_at_price > variant_price -%} {{ 'product.price.regular_price' | t }} {%- if settings.currency_code_enabled -%} {{- variant_compare_at_price | money_with_currency -}} {%- else -%} {{- variant_compare_at_price | money -}} {%- endif -%} {%- endif -%} {%- elsif line_item != blank -%} {%- comment -%} -------------------------------------------------------------------------------------------------------------------- LINE ITEM CASE (used on cart, order page...) -------------------------------------------------------------------------------------------------------------------- {%- endcomment -%} {{ 'product.price.sale_price' | t }} {%- if settings.currency_code_enabled -%} {{- line_item.final_line_price | money_with_currency -}} {%- else -%} {{- line_item.final_line_price | money -}} {%- endif -%} {%- if line_item.original_line_price > line_item.final_line_price -%} {{ 'product.price.regular_price' | t }} {%- if settings.currency_code_enabled -%} {{- line_item.original_line_price | money_with_currency -}} {%- else -%} {{- line_item.original_line_price | money -}} {%- endif -%} {%- endif -%} {%- else -%} {%- comment -%} -------------------------------------------------------------------------------------------------------------------- PRODUCT CASE (used on card) -------------------------------------------------------------------------------------------------------------------- {%- endcomment -%} {%- if product.price_varies and product.compare_at_price -%} {%- assign cheapest_variant = product.variants | sort: 'price' | first -%} {%- liquid assign cheapest_variant_price = cheapest_variant.price assign cheapest_variant_compare_at_price = cheapest_variant.price if cheapest_variant.metafields.app--168074346497.discount_type.value != nil and cheapest_variant.metafields.app--168074346497.discount_type.value != "fixed" and product.metafields.app--168074346497.discount_percentage.value > 0.01 assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value if cheapest_variant.metafields.app--168074346497.discount_percentage.value > 0.01 assign deducted_percentage = 1.0 | minus: cheapest_variant.metafields.app--168074346497.discount_percentage.value endif assign cheapest_variant_price = cheapest_variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil assign cheapest_variant_compare_at_price = cheapest_variant.price if cheapest_variant.compare_at_price > cheapest_variant_compare_at_price assign cheapest_variant_compare_at_price = cheapest_variant.compare_at_price endif elsif cheapest_variant.metafields.app--168074346497.discount_type.value == "fixed" assign cheapest_variant_price = cheapest_variant.metafields.app--168074346497.auto_discounted_price.value assign cheapest_variant_compare_at_price = cheapest_variant.price if cheapest_variant.compare_at_price > cheapest_variant_compare_at_price assign cheapest_variant_compare_at_price = cheapest_variant.compare_at_price endif endif -%} {%- capture price_min -%} {%- if settings.currency_code_enabled -%} {{- cheapest_variant_price | money_with_currency -}} {%- else -%} {{- cheapest_variant_price | money -}} {%- endif -%} {%- endcapture -%} {%- if cheapest_variant_price < cheapest_variant_compare_at_price -%} {{ 'product.price.sale_price' | t }} {{- 'product.price.from_price_html' | t: price_min: price_min -}} {{ 'product.price.regular_price' | t }} {%- if settings.currency_code_enabled -%} {{- cheapest_variant_compare_at_price | money_with_currency -}} {%- else -%} {{- cheapest_variant_compare_at_price | money -}} {%- endif -%} {%- else -%} {{ 'product.price.sale_price' | t }} {{- 'product.price.from_price_html' | t: price_min: price_min -}} {%- endif -%} {%- elsif product_price < product_compare_at_price -%} {{ 'product.price.sale_price' | t }} {%- if settings.currency_code_enabled -%} {{- product_price | money_with_currency -}} {%- else -%} {{- product_price | money -}} {%- endif -%} {{ 'product.price.regular_price' | t }} {%- if settings.currency_code_enabled -%} {{- product_compare_at_price | money_with_currency -}} {%- else -%} {{- product_compare_at_price | money -}} {%- endif -%} {%- elsif product.price_varies -%} {%- capture price_min -%} {%- if settings.currency_code_enabled -%} {{ product_price_min | money_with_currency }} {%- else -%} {{ product_price_min | money }} {%- endif -%} {%- endcapture -%} {%- capture price_max -%} {%- if settings.currency_code_enabled -%} {{- product_price_max | money_with_currency -}} {%- else -%} {{- product_price_max | money -}} {%- endif -%} {%- endcapture -%} {{ 'product.price.sale_price' | t }} {{- 'product.price.from_price_html' | t: price_min: price_min, price_max: price_max -}} {%- else -%} {{ 'product.price.sale_price' | t }} {%- if settings.currency_code_enabled -%} {{- product_price | money_with_currency -}} {%- else -%} {{- product_price | money -}} {%- endif -%} {%- endif -%} {%- endif -%} {%- unless hide_unit_price -%} {%- assign unit_price_item = variant | default: line_item | default: product.selected_or_first_available_variant -%} {%- if unit_price_item.unit_price -%} {%- assign unit_price_measurement = unit_price_item.unit_price_measurement -%} {%- if unit_price_measurement.reference_value != 1 -%} {%- assign reference_value = unit_price_measurement.reference_value -%} {%- endif -%} ({{ unit_price_item.unit_price | money }}/{{ reference_value }}{{ unit_price_measurement.reference_unit }}) {%- endif -%} {%- endunless -%}