Add deducted percentage metafield to price-list snippet

Add deducted percentage metafield to price-list snippet
This commit is contained in:
Axel 2025-05-27 11:53:48 +08:00
parent 7609909121
commit c877a83398

View File

@ -47,6 +47,12 @@
{% if variant.metafields.app--168074346497.auto_discounted_price.value %}
{% if variant.metafields.app--168074346497.auto_discounted_price.value < variant_case_price %}
{% assign variant_case_price = variant.metafields.app--168074346497.auto_discounted_price.value %}
{% if product.metafields.app--168074346497.discount_percentage.value > 0.01 %}
{% assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value %}
{% assign variant_case_price = variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil %}
{% endif %}
{% assign variant_case_compare_at_price = variant.price %}
{% if variant.compare_at_price > variant.price %}
@ -139,6 +145,12 @@
if product.metafields.app--168074346497.min_auto_discounted_price.value < variant.price
if settings.currency_code_enabled
assign variant_price = product.metafields.app--168074346497.min_auto_discounted_price.value | money_with_currency
if product.metafields.app--168074346497.discount_percentage.value > 0.01
assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value
assign variant_price = variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil | money_with_currency
endif
assign variant_compare_at_price = variant.price | money_with_currency
if variant.compare_at_price > variant.price
@ -146,6 +158,12 @@
endif
else
assign variant_price = product.metafields.app--168074346497.min_auto_discounted_price.value | money
if product.metafields.app--168074346497.discount_percentage.value > 0.01
assign deducted_percentage = 1.0 | minus: product.metafields.app--168074346497.discount_percentage.value
assign variant_price = variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil | money
endif
assign variant_compare_at_price = variant.price | money
if variant.compare_at_price > variant.price