Skip to content

Instantly share code, notes, and snippets.

@airarm
Created October 24, 2023 07:04
Show Gist options
  • Save airarm/6ffa86b234c6dba739efab4c562f630b to your computer and use it in GitHub Desktop.
Save airarm/6ffa86b234c6dba739efab4c562f630b to your computer and use it in GitHub Desktop.
{% assign cart_com_total_price = 0 %}
{% for line_item in cart.items %}
{% if line_item.product.compare_at_price %}
{% assign com_price = line_item.product.compare_at_price | times: line_item.quantity %}
{% assign cart_com_total_price = cart_com_total_price | plus: com_price %}
{% else %}
{% assign cart_com_total_price = cart_com_total_price | plus: line_item.final_price %}
{% endif %}
{% endfor %}
{% if cart_com_total_price > cart.total_price %}
{% assign total_price_diff = cart.total_price | minus: cart_com_total_price %}
<div>
<span style="color:green;">Savings</span>
<span style="color:green;">{{ total_price_diff | money }}</span>
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment