Re: how to show sale% on the badge.

How can I display the sale percentage on the badge in Dawn theme?

saitejabandaru
Excursionist
16 0 4

Hi Legends, i hope everyone is doing great..

I need a small help..

Iam using Dawn theme..and if a product is on sale it just shows as sale.. but how can i show the % on the badge as well?  

any help would be appreciated..:)

Thanks in advance:)

Replies 5 (5)

Zworthkey
Shopify Partner
5581 642 1579
{% if product.compare_at_price_max > product.price %}You Save {{ product.compare_at_price_max | minus: product.price | times: 100.0 | divided_by: product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0'}}% {% endif %}

@saitejabandaru 
try this code in the Product-template.liquid file. 

it show the % and the remaining will be the custom code where you want to Display this into your Product.

 

saitejabandaru
Excursionist
16 0 4

Thanks for the reply @Zworthkey 

I actually want it to appear on all of sales badges..home page ..product recommendations..how can i do that and wher can i paste the code ? 

Zworthkey
Shopify Partner
5581 642 1579

@saitejabandaru 

Where you want to show paste their code.

 

Zworthkey
Shopify Partner
5581 642 1579

@saitejabandaru 

it's total customization work. and on which products you want to show the badges. 
how much % like '10% save' .
For all this it takes time and you need a Developer for this.

or hire Someone to add these features into store. let me know if you need help from us.
We are always happy to help you.

Thank you.

gr_trading
Shopify Partner
1943 145 203

Hi @saitejabandaru ,

 

To implement this you have to update the code for card-product.liquid to show impact globally.

 

Please refer the below code to implement the same.

 

{%- assign difference = card_product.compare_at_price | minus: card_product.price -%}
{%- assign float_difference = difference | times: 1.0 -%}
{%- assign discount_fraction = float_difference | divided_by: card_product.compare_at_price -%}
{%- assign discount_percentage = discount_fraction | times: 100 | round -%}
{{- discount_percentage }}

 

 

For line number where to update the code and implement it on product page kindly refer the below video.

 

Hope this will helps..

For any custom development WhatsApp or connect at Email ID: [email protected] for quick consultation. | Shopify Free codes
To support Buy Me a Coffee