Adding total discount from all items to invoice

I use order printer for my invoice template. it shows a line for total discounts, but that only adds up if the discount is from a discount code or a coupon. I want to add the html code in there so that it can take the difference between the compare price and what they actually paid and add that up for all items so they can actually see what they saved on the order. Is there a way to add code to the discount line that adds up this difference in the compare price and actual price when using that sort of sale?

Search first https://community.shopify.com/search?q=total+discount+invoice+template
It’s a literal rule and can save everyone time from collective efforts IF they exist.

It’s liquid that would do the logic not html.
Roughly inside the loop over line items set a total variable and adding in the current difference
PSEUDO code

{% for ... 
  {% assign total_discounts %}
  ...
  {% assign price_difference = item.compare_at_price | minus: item.price
  ..
  {% assign total_discounts | plus: price_difference %}
{% endfor %}

If you need the full business logic work done for you can reach out to me for customization services.
:speaking_head: :postbox: CLICK profile-pic on forums for options to connect.
ALWAYS include context in new communications, e.g. reference urls, posts urls, etc

Hi @luvnstore

Place this below your discount section, or wherever you want the “Savings” line to show:

{% assign total_savings = 0 %}

{% for line_item in line_items %}
  {% if line_item.compare_at_price > line_item.price %}
    {% assign item_savings = line_item.compare_at_price | minus: line_item.price %}
    {% assign item_savings_total = item_savings | times: line_item.quantity %}
    {% assign total_savings = total_savings | plus: item_savings_total %}
  {% endif %}
{% endfor %}

{% if total_savings > 0 %}
  <tr class="total-line total-line--savings">
    <th class="total-line__name">Total Savings</th>
    <td class="total-line__price">{{ total_savings | money }}</td>
  </tr>
{% endif %}

Best regards,
Devcoder :laptop: