I have on my store an automated total savings in cart calculator with a code but I only want to show it when there is saving/discount, how can I go about that?
Hi @perfumecartel ,
Welcome to the community,
Can you please share the code and the Store URL
I may assist you further ![]()
Estás ahorrando:{% assign total_saving = 0 %}
{%- for item in cart.items -%}
{% if item.variant.compare_at_price > item.variant.price %}
{% assign saving = item.variant.compare_at_price | minus: item.variant.price %}
{% if item.quantity > 1 %}
{% assign saving = saving | times: item.quantity %}
{% endif %}
{% assign total_saving = saving | plus: total_saving %}
{% endif %}
{% endfor %}
{% if cart.total_discount > 0 %}
Your discount: {{ cart.total_discount | money }}
{% endif %}{{ total_saving | money }}
(there is some extra stuff that the code doesn’t need for the code to work because I tried to do it myself)