Add total savings to Subtotal

Solved

Add total savings to Subtotal

Sean_Morton34
Tourist
3 0 1

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 %}
<s>{{ item.variant.compare_at_price | money }}</s>
{% 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

Screenshot 2024-06-11 090714.jpg

Accepted Solutions (2)

nvchien
Shopify Partner
55 23 13

This is an accepted solution.

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

 <div class="totals-compare">
   {{ subtotalCompare | money }}
 </div>

 

Hope this helps!

- If this solution helped you out, please consider accepting it as a solution and giving it a thumbs-up. Your feedback is valuable to me and the community!
- If you're feeling extra generous, you can always buy me a coffee . Your support helps fuel my Shopify knowledge and keeps the solutions flowing!
- You can also follow more tips and tricks from my blog.

View solution in original post

nvchien
Shopify Partner
55 23 13

This is an accepted solution.

@Sean_Morton34 

 

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

 <s>
   {{ subtotalCompare | money }}
 </s>
- If this solution helped you out, please consider accepting it as a solution and giving it a thumbs-up. Your feedback is valuable to me and the community!
- If you're feeling extra generous, you can always buy me a coffee . Your support helps fuel my Shopify knowledge and keeps the solutions flowing!
- You can also follow more tips and tricks from my blog.

View solution in original post

Replies 4 (4)

nvchien
Shopify Partner
55 23 13

This is an accepted solution.

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

 <div class="totals-compare">
   {{ subtotalCompare | money }}
 </div>

 

Hope this helps!

- If this solution helped you out, please consider accepting it as a solution and giving it a thumbs-up. Your feedback is valuable to me and the community!
- If you're feeling extra generous, you can always buy me a coffee . Your support helps fuel my Shopify knowledge and keeps the solutions flowing!
- You can also follow more tips and tricks from my blog.
Sean_Morton34
Tourist
3 0 1

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.

Sean_Morton34_0-1718124608471.png

 

Thanks,

Sean

nvchien
Shopify Partner
55 23 13

This is an accepted solution.

@Sean_Morton34 

 

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

 <s>
   {{ subtotalCompare | money }}
 </s>
- If this solution helped you out, please consider accepting it as a solution and giving it a thumbs-up. Your feedback is valuable to me and the community!
- If you're feeling extra generous, you can always buy me a coffee . Your support helps fuel my Shopify knowledge and keeps the solutions flowing!
- You can also follow more tips and tricks from my blog.
Sean_Morton34
Tourist
3 0 1

I got it! Thank you so much!