{% 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 %}