Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi everyone,
I'm trying to modify my `card-product.liquid` file to display the amount of money saved on each product instead of the default "Sale" label. I followed the instructions and code provided by an AI, and also consulted the guide in this [Shopify Community post](https://community.shopify.com/c/shopify-design/how-to-make-a-quot-sale-quot-label-show-quot-save-x-q...), but it's not working as expected.
Here's the line of code I added to my script:
```liquid
{%- assign savings = card_product.compare_at_price | minus: card_product.price -%}
Save ${{ savings }}
```
I also tried the revised code to calculate and show the percentage savings:
```liquid
{%- assign savings = card_product.compare_at_price | minus: card_product.price -%}
{%- if card_product.compare_at_price > 0 -%}
{%- assign savings_percentage = savings | times: 100 | divided_by: card_product.compare_at_price -%}
Save {{ savings_percentage | round: 2 }}%
{%- endif -%}
```
Despite adding the `compare_at_price` and `price` for each variant in bulk edit, the amount of money saved doesn't display live on my product cards.
Can someone please help me figure out what I'm doing wrong? Any advice on how to correctly implement this feature would be greatly appreciated!
Thank you!
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024