Sale: Percent off Liquid
Product pages
Liquid code:
{% if current_variant.compare_at_price > current_variant.price %}
{% assign savings = product.compare_at_price | minus: product.price | times: 0.01 %}
{% assign savings_calc = product.compare_at_price | divided_by: savings | times: 0.01 %}
{% assign savings_percent = 100 | divided_by: savings_calc %}
{{ savings_percent | round }}% off
{% endif %}
Example to add on product page (snippets folder):

Result:

Collection pages
Liquid code:
{% assign savings = product.compare_at_price | minus: product.price | times: 0.01 %}
{% assign savings_calc = product.compare_at_price | divided_by: savings | times: 0.01 %}
{% assign savings_percent = 100 | divided_by: savings_calc %}
{{ savings_percent | round }}% off
Example for collection pages (snippets folder):

Result:
