{{ 'content.product_badge_sale' | t }}{% assign savings = product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round %}
Save {{ savings }}%BLOCK :
{% if product.compare_at_price > product.price %}
{% assign savings = product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round %}
<div class="product-badges__badge product-badges__badge--rectangle" style="display: inline-block; background: var(--color-foreground); color: var(--color-background); padding: 4px 8px; border-radius: 4px;">
Save {{ savings }}%
</div>
{% endif %}
Previous themes : snippets/card-product.liquid
{{- 'products.product.on_sale' | t -}}
Replace two times :
{% assign savings = card_product.compare_at_price | minus: card_product.price | times: 100.0 | divided_by: card_product.compare_at_price | round %}
Save {{ savings }}%
snippets/price.liquid
{{ 'products.product.on_sale' | t }}
replace
{% assign savings = compare_at_price | minus: price | times: 100.0 | divided_by: compare_at_price | round %}
Save {{ savings }}%
