design

How can I modify the sale badge from percentage to the word “sale” in Shopify?

1 Like
  • Look for the file where the sale badge is generated. This is usually in a Liquid file like product-card.liquid, product-grid-item.liquid, product-template.liquid, or similar.

  • Common locations for these files are in the Snippets folder or within the Sections folder.

  • Look for code that generates the sale badge, which might look something like this:

{% if product.compare_at_price > product.price %}
  {{ product.compare_at_price | minus: product.price | divided_by: product.compare_at_price | times: 100 | round }}% Off
{% endif %}
  • Replace the percentage display with the text “SALE”. Your updated code might look like this:
{% if product.compare_at_price > product.price %}
  SALE
{% endif %}
  • Click Save to apply your changes.

  • If you can not do it, please contact me for help.

  • Please press ‘Like’ and mark it as ‘Solution’ if you find it helpful. Thank you.

1 Like

thanks, it worked to an extent, i dont quit understand code, so i want the word sale to be in a label

{%- assign sale_percent = price | times: 100 | divided_by: compare_at_price | minus: 100 | times: -1 -%}

{{ 'products.product.label.sale' | t: percent: sale_percent }}

{%- assign has_labels = true -%}

{%- else -%}

this is the code i found