Add total savings to Subtotal

Topic summary

A user seeks to display total savings (based on compare-at prices) in the cart subtotal section, showing the original price with a strikethrough alongside the discounted price.

Initial Solution:

  • Code provided to calculate total compare-at price across all cart items
  • Uses Liquid templating to loop through cart items and sum compare prices
  • Applies HTML <s> tag for strikethrough styling

Implementation Details:

  • Works in main cart page (Main-Cart-items.liquid)
  • Original poster successfully implemented the solution
  • Prefers automatic display over discount code apps

Ongoing Issue:

  • Another user (andreas23) reports the code doesn’t work in cart-drawer.liquid
  • Product page shows correct compare prices (e.g., $200 $119)
  • Cart drawer displays incorrect pricing, preventing customers from seeing the comparison
  • Issue remains unresolved for the cart drawer implementation
Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

Hello All,

I know that this is a common topic of discussion but I wanted to see if there was a way to get the compared price above the subtotal in my cart. The image attached is to better explain what I would like help on. I already played around with the CSS for Main-Cart-items.liquid.

I added this code to get it under my actual product -
{% if item.variant.compare_at_price > item.variant.price %}
{{ item.variant.compare_at_price | money }}
{% endif %}

I am curious to see if I could get it on the actual total and subtotal sections. I am using the Shrine Theme currently. I have been trying to find every possible answer to fix this but nothing is helping. I would prefer not to use an app because I would like it to be automatic instead of a having to add a discount code.

My URL is - https://sweet-dreamzzz.com/cart

I would appreciate any help on this.

Thanks,

Sean

Hi @Sean_Morton34 ,

It is possible to do, you can do something like this:

(Note: Please update this code in *.liquid file of cart page)

1/ Calculate total compare price:

{% assign subtotalCompare = 0 %}
{% for item in cart.items %}
  {% if item.variant.compare_at_price > item.variant.price %}
     {% assign subtotalCompare = subtotalCompare | plus: item.variant.compare_at_price %}
  {% endif %}
{% endfor %}

2/ Print total compare price


   {{ subtotalCompare | money }}
 

Hope this helps!

1 Like

Hi Nvchien!

Thank you! it worked but I wanted to see if there ways a way to get the line through it? Below is what I see now.

Thanks,

Sean

@Sean_Morton34

For line through, you can use tag in html, for example:

<s>
   {{ subtotalCompare | money }}
 </s>
1 Like

I got it! Thank you so much!

1 Like

Hi! sorry I tried copying the code you provided in the cart-drawer.liquid

as :

{% assign subtotalCompare = 0 %}
{% for item in cart.items %}
{% if item.variant.compare_at_price > item.variant.price %}
{% assign subtotalCompare = subtotalCompare | plus: item.variant.compare_at_price %}
{% endif %}
{% endfor %}

{{ subtotalCompare | money }}
{{ subtotalCompare | money }}

but is not working! the price in the landing page still shows the compared price $119 instead of $200, but once I add the product to the cart I do not see the comparison which is not good. I want customers to see that.. any help? thank you @Sean_Morton34

image 1. Showing the cart drawer
image 2. Showing the prices on product page