We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

How can I alter the sale badge to display percentages?

Solved

How can I alter the sale badge to display percentages?

Nico38
Trailblazer
172 5 61

Hello how to change sale badge for percentage? 

Accepted Solution (1)

LitExtension
Shopify Partner
4963 1010 1192

This is an accepted solution.

Hi @Nico38,

Go to snippets > card-product.liquid file, in line 93 and change code:

beforebeforeafterafter

Code:

{%- assign percent = card_product.compare_at_price | minus: card_product.price | times: 100 | divided_by: card_product.compare_at_price | round -%}
              <span class="badge badge--bottom-left color-{{ settings.sale_badge_color_scheme }}">-{{ percent }}%</span>
LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com

View solution in original post

Replies 11 (11)

paulryazanov
Shopify Partner
104 10 26

Hi! Please, provide link to your site and name of theme

CEO of MageCloud.agency

MS_WEB_DESIGNER
Shopify Partner
695 52 135

Hi @Nico38,

I am Ani From https://www.task4store.com/  - Shopify Small & Custom Tasks Experts ( By MS Web Designer - Top Rated Shopify Certified Experts and eCommerce Consultant from Singapore )

I will love to help you with your concern.

-Kindly Provide your Store Url,
-Also Mention Which Shopify theme you are using 

Note: If your store is protected with ‘store Font password’ please Send it here or DM me.

If you have any concerns feel free to ask me!

Regards,
Ani

banned

LitExtension
Shopify Partner
4963 1010 1192

This is an accepted solution.

Hi @Nico38,

Go to snippets > card-product.liquid file, in line 93 and change code:

beforebeforeafterafter

Code:

{%- assign percent = card_product.compare_at_price | minus: card_product.price | times: 100 | divided_by: card_product.compare_at_price | round -%}
              <span class="badge badge--bottom-left color-{{ settings.sale_badge_color_scheme }}">-{{ percent }}%</span>
LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com
Nico38
Trailblazer
172 5 61

work perfectly thx you very much @LitExtension 

eComSeller97
Tourist
11 0 2

Hello

I'm using Debut theme with PageFly to create a product grid. I chose the collection I want to display its products and everything is fine but the problem is : some products are on sale and others aren't, so the "product badge that shows the % of discount" keep appearing in every product even for the products who have "no compare at price" (which means aren't in sale) so the badge appears "%0 discount"

 

I want to edit the code to make the badge appear only when : product.compare_at_price_max > product.price

There is a CSS code section in PageFly so I can edit whatever I want but I don't know how to code this condtion of display.product badge.png

mzhashmi
Visitor
1 0 0

Hi. Thanks this works well with my craft theme. But, I want to show the same badge on every product's page. In this solution, the sales percentage is shown in the collection grid but not on the product page. Can you help? Thank you

HomeLiving
Visitor
1 0 0

Looking for this same solution, this worked for the collection page but looking to replicate on product page


Thanks in advance

LitExtension
Shopify Partner
4963 1010 1192

Hi @HomeLiving,

You can create a question on the community and send me the link. I will check it.
Because this will help build a better community.
Thank you.

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com
Blue_wave
Shopify Partner
4 0 0

how to change percentage on different variation

BigBenjamin
Visitor
3 0 0

Hello, seems like this has changed, I found the same code at the line 328 but when I paste your code, nothing changes. Would be great if you could look into that, I attached a screenshot below

BigBenjamin_0-1692099967969.png

 

 

dinina
Excursionist
18 0 10

what if my theme does not have card_product liquid file? i a, using District theme and i am facing difficulties , i tried all tutorials and they are made for the dawn theme