Skip to content

Instantly share code, notes, and snippets.

@atikju
Last active October 2, 2018 17:18
Show Gist options
  • Save atikju/6ff862c99318708f3ca50599d98ec2a5 to your computer and use it in GitHub Desktop.
Save atikju/6ff862c99318708f3ca50599d98ec2a5 to your computer and use it in GitHub Desktop.
Shopify - Display Total Savings on Cart
{% 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 | times: item.quantity %}
{% assign total_saving = saving | plus: total_saving %}
{% endif %}
{% endfor %}
You Saved: {{ total_saving }} //example: $40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment