Re: 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 14

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!
- You can also follow more tips and tricks from my blog.
- Find me on Linkedin

View solution in original post

nvchien
Shopify Partner
55 23 14

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!
- You can also follow more tips and tricks from my blog.
- Find me on Linkedin

View solution in original post

Replies 5 (5)

nvchien
Shopify Partner
55 23 14

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!
- You can also follow more tips and tricks from my blog.
- Find me on Linkedin
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 14

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!
- You can also follow more tips and tricks from my blog.
- Find me on Linkedin
Sean_Morton34
Tourist
3 0 1

I got it! Thank you so much! 

andreas23
New Member
6 0 0

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 %}
<div class="totals-compare">
{{ subtotalCompare | money }}
</div>
<s>
{{ subtotalCompare | money }}
</s>

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



Screenshot 2024-09-22 at 17.52.13.pngScreenshot 2024-09-22 at 17.51.47.png