{% 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 %}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter