Add modified code

This commit is contained in:
Axel
2026-06-29 13:47:42 +08:00
parent 9faedaa44d
commit 539e579964
3 changed files with 143 additions and 35 deletions
+100 -27
View File
@@ -41,30 +41,77 @@ Supported variables
-%}
<price-list class="price-list {% if size == 'lg' %}price-list--lg{% endif %} {% if text_alignment == 'center' %}justify-center{% endif %}">
{%- 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 -%}
<sale-price class="{% if variant.compare_at_price > variant.price %}{{ on_sale_price_classes }}{% else %}{{ regular_price_classes }}{% endif %}">
<sale-price class="{% if variant_compare_at_price > variant_price %}{{ on_sale_price_classes }}{% else %}{{ regular_price_classes }}{% endif %}">
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
{%- if settings.currency_code_enabled -%}
{{- variant.price | money_with_currency -}}
{{- variant_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- variant.price | money | replace: 'MYR', '' -}}
{{- variant_price | money | replace: 'MYR', '' -}}
{%- endif -%}
</sale-price>
{%- if variant.compare_at_price > variant.price -%}
{%- if variant_compare_at_price > variant_price -%}
<compare-at-price class="{{ compare_at_price_classes }}">
<span class="sr-only">{{ 'product.price.regular_price' | t }}</span>
{%- if settings.currency_code_enabled -%}
{{- variant.compare_at_price | money_with_currency -}}
{{- variant_compare_at_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- variant.compare_at_price | money | replace: 'MYR', '' -}}
{{- variant_compare_at_price | money | replace: 'MYR', '' -}}
{%- endif -%}
</compare-at-price>
{%- endif -%}
@@ -78,7 +125,7 @@ Supported variables
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
{%- if settings.currency_code_enabled -%}
{{- line_item.final_line_price | money_with_currency -}}
{{- line_item.final_line_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- line_item.final_line_price | money | replace: 'MYR', '' -}}
{%- endif -%}
@@ -89,7 +136,7 @@ Supported variables
<span class="sr-only">{{ 'product.price.regular_price' | t }}</span>
{%- if settings.currency_code_enabled -%}
{{- line_item.original_line_price | money_with_currency -}}
{{- line_item.original_line_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- line_item.original_line_price | money | replace: 'MYR', '' -}}
{%- endif -%}
@@ -104,22 +151,48 @@ Supported variables
{%- 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 -}}
{{- cheapest_variant_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- cheapest_variant.price | money | replace: 'MYR', '' -}}
{{- cheapest_variant_price | money | replace: 'MYR', '' -}}
{%- endif -%}
{%- endcapture -%}
{%- if cheapest_variant.price < cheapest_variant.compare_at_price -%}
{%- if cheapest_variant_price < cheapest_variant_compare_at_price -%}
<compare-at-price class="{{ compare_at_price_classes }}">
<span class="sr-only">{{ 'product.price.regular_price' | t }}</span>
{%- if settings.currency_code_enabled -%}
{{- cheapest_variant.compare_at_price | money_with_currency -}}
{{- cheapest_variant_compare_at_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- cheapest_variant.compare_at_price | money | replace: 'MYR', '' -}}
{{- cheapest_variant_compare_at_price | money | replace: 'MYR', '' -}}
{%- endif -%}
</compare-at-price>
@@ -133,41 +206,41 @@ Supported variables
{{- 'product.price.from_price_html' | t: price_min: price_min -}}
</sale-price>
{%- endif -%}
{%- elsif product.price < product.compare_at_price -%}
<compare-at-price class="{{ compare_at_price_classes }}">
{%- elsif product_price < product_compare_at_price -%}
<compare-at-price class="{{ compare_at_price_classes }}">
<span class="sr-only">{{ 'product.price.regular_price' | t }}</span>
{%- if settings.currency_code_enabled -%}
{{- product.compare_at_price | money_with_currency -}}
{{- product_compare_at_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- product.compare_at_price | money | replace: 'MYR', '' -}}
{{- product_compare_at_price | money | replace: 'MYR', '' -}}
{%- endif -%}
</compare-at-price>
<sale-price class="{{ on_sale_price_classes }}">
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
{%- if settings.currency_code_enabled -%}
{{- product.price | money_with_currency -}}
{{- product_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- product.price | money | replace: 'MYR', '' -}}
{{- product_price | money | replace: 'MYR', '' -}}
{%- endif -%}
</sale-price>
{%- elsif product.price_varies -%}
{%- capture price_min -%}
{%- if settings.currency_code_enabled -%}
{{ product.price_min | money_with_currency | replace: 'MYR', ''}}
{{ product_price_min | money_with_currency | replace: 'MYR', '' }}
{%- else -%}
{{ product.price_min | money | replace: 'MYR', '' }}
{{ product_price_min | money | replace: 'MYR', '' }}
{%- endif -%}
{%- endcapture -%}
{%- capture price_max -%}
{%- if settings.currency_code_enabled -%}
{{- product.price_max | money_with_currency -}}
{{- product_price_max | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- product.price_max | money | replace: 'MYR', '' -}}
{{- product_price_max | money | replace: 'MYR', '' -}}
{%- endif -%}
{%- endcapture -%}
@@ -180,9 +253,9 @@ Supported variables
<span class="sr-only">{{ 'product.price.sale_price' | t }}</span>
{%- if settings.currency_code_enabled -%}
{{- product.price | money_with_currency -}}
{{- product_price | money_with_currency | replace: 'MYR', '' -}}
{%- else -%}
{{- product.price | money | replace: 'MYR', '' -}}
{{- product_price | money | replace: 'MYR', '' -}}
{%- endif -%}
</sale-price>
{%- endif -%}