Add compare at price

Add compare at price
This commit is contained in:
2025-08-29 16:26:00 +00:00
parent 293566f1b4
commit 83d97bacb1

View File

@@ -122,21 +122,31 @@ Supported variables
{%- endif -%}
{%- if show_prices and product.template_suffix != 'quote' -%}
<div class="product-price">
{% assign v = product.selected_or_first_available_variant %}
{% assign variant_price = product.selected_or_first_available_variant.price %}
{% if v.metafields.app--168074346497.discount_type.value != nil and v.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 %}
{% assign v = product.selected_or_first_available_variant %}
{% assign variant_price = v.price %}
{% assign variant_compare_at_price = v.compare_at_price %}
{% if v.metafields.app--168074346497.discount_type.value != nil and v.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 v.metafields.app--168074346497.discount_percentage.value > 0.01 %}
{% assign deducted_percentage = 1.0 | minus: v.metafields.app--168074346497.discount_percentage.value %}
{% endif %}
{% assign variant_price = v.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil %}
{% if v.metafields.app--168074346497.discount_percentage.value > 0.01 %}
{% assign deducted_percentage = 1.0 | minus: v.metafields.app--168074346497.discount_percentage.value %}
{% endif %}
{% assign variant_price = v.price | divided_by: 100.0 | times: deducted_percentage | times: 100.0 | ceil %}
{% assign variant_compare_at_price = v.price %}
{% if v.compare_at_price > variant_compare_at_price %}
{% assign variant_compare_at_price = v.compare_at_price %}
{% endif %}
{% endif %}
<div class="product-price">
{{ variant_price | money }}
</div>
{% if variant_compare_at_price %}
<compare-at-price class="text-subdued line-through">
{{ variant_compare_at_price | money }}
</compare-at-price>
{% endif %}
{%- endif -%}
</div>
</div>
@@ -305,4 +315,3 @@ Supported variables
}
});
</script>