Show discount on variant buttons
Thu Sep 22 2022 20:35:17 GMT+0000 (Coordinated Universal Time)
Saved by
@wren_digital
{% assign savings = false %}
{% assign option_variant = product.variants[forloop.index0] %}
{% if option_variant.price < option_variant.compare_at_price %}
{% assign savings = option_variant.compare_at_price | minus: option_variant.price | times: 100.0 | divided_by: option_variant.compare_at_price | money_without_currency | times: 100 | remove: '.0' | append: '% Off' %}
{% endif %}
{% if savings %}
<div class="savings">{{ savings }}</div>
{% endif %}
content_copyCOPY
Comments