calculate variant and product price based on discount percentage

calculate variant and product price based on discount percentage
This commit is contained in:
Axel 2025-05-27 12:08:44 +08:00
parent c877a83398
commit ea8dcf6213

View File

@ -54,6 +54,12 @@ Supported variables
if variant.metafields.app--168074346497.auto_discounted_price.value
if variant.metafields.app--168074346497.auto_discounted_price.value < variant.price
assign variant_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_price = variant.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
endif
assign variant_compare_at_price = variant.price
if variant.compare_at_price > variant.price
@ -65,6 +71,12 @@ Supported variables
if product.metafields.app--168074346497.min_auto_discounted_price.value
if product.metafields.app--168074346497.min_auto_discounted_price.value < product.price
assign product_price = product.metafields.app--168074346497.min_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 product_price = product.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil
endif
assign product_compare_at_price = product.price
if product.compare_at_price > product.price