I’m looking for a way to change the sale Badge into a percentage off sign. I was looking into the community for answers, but these are all outdated, the new Edit code tab and I think my theme is also different from all the tutorials I could find.
Hi snnap — the tutorials feel outdated because they edit a label your theme now renders slightly differently, but the underlying trick is the same and it’s just a few lines.
Your badge appears wherever the theme detects compare_at_price > price. Instead of printing “Sale”, compute the discount:
times: 100 before divided_by keeps a clean integer percent (Liquid does integer math). For rounding instead of flooring: | times: 100.0 | divided_by: product.compare_at_price | round.
Where to put it: search your theme for the current badge — in Fabric it’s usually a snippet used by the card and the product page, and the label comes from a translation key (search the code for on_sale or the text “Sale”). Swap that label for the block above.
One honest caveat: on a product with several variants at different discounts, product.compare_at_price / product.price are the min/max across variants, so the % can look off. On the product page, compute from the selected variant (product.selected_or_first_available_variant) instead; on the card the product-level version is usually fine.
Paste the snippet where “Sale” currently prints (file name + those few lines) and I’ll give you the exact drop-in for 4.1.1.
Since you are using the Fabric theme (v4.1.1), you might not even need to write any custom code! Often have this setting built natively into the theme editor.
Here is how you can check and apply this:
Go to your Shopify Admin > Online Store > Themes > click Customize on your Fabric theme.
On the far-left sidebar, click the Gear icon (Theme Settings).
Look for a section called Badges (or sometimes Product Grid / Products).
Look for a dropdown option like Sale badge format or Discount type. You should be able to change it from “Text” to “Percentage” or “Percent off” right there.
Both issues have the same cause: our earlier edit was in blocks/_product-card-gallery.liquid, which only runs on product cards, not the product page. And product.compare_at_price/product.price is the default-variant price, so the % is wrong once another variant is picked.
Sol: put the badge in the price snippet, based on the selected variant.
snippets/price.liquid — after assign show_compare_price = ... add:
I’m sending you the theme. I haven’t made any changes to the sale badge percentage in this theme yet, so you can apply all the necessary changes from scratch. It would be really helpful for me. Thanks!