Solved

how to show percentage near product price on main page.

labelnumaani
Visitor
2 0 0

Now

labelnumaani_1-1708520118910.png

I want like this 

labelnumaani_0-1708520088294.png

 


how can i achieve this. Please Help

Accepted Solution (1)
webwondersco
Shopify Partner
1046 159 156

This is an accepted solution.

@labelnumaani Add the below code just in your price snippet where you want to display the % off.

 

{% if product.compare_at_price_max > product.price %}
{{ 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 %}
Web Wonders | Shopify Partner | Connect here!
- Question answered? Mark as Accepted Solution, reply helpful? Click Like
- Hire me, if you want to design, re-design, develop a store, or make changes to the pre-built store.
a small Coffee Tip would be greatly appreciated. 🙂

View solution in original post

Replies 3 (3)

webwondersco
Shopify Partner
1046 159 156

@labelnumaani Hope you are doing well.

 

Could you please share your store URL? and also share which theme you are using.

Web Wonders | Shopify Partner | Connect here!
- Question answered? Mark as Accepted Solution, reply helpful? Click Like
- Hire me, if you want to design, re-design, develop a store, or make changes to the pre-built store.
a small Coffee Tip would be greatly appreciated. 🙂
labelnumaani
Visitor
2 0 0
webwondersco
Shopify Partner
1046 159 156

This is an accepted solution.

@labelnumaani Add the below code just in your price snippet where you want to display the % off.

 

{% if product.compare_at_price_max > product.price %}
{{ 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 %}
Web Wonders | Shopify Partner | Connect here!
- Question answered? Mark as Accepted Solution, reply helpful? Click Like
- Hire me, if you want to design, re-design, develop a store, or make changes to the pre-built store.
a small Coffee Tip would be greatly appreciated. 🙂