Shopify themes, liquid, logos, and UX
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
Solved! Go to the solution
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!
This is an accepted solution.
For line through, you can use <s> tag in html, for example:
<s>
{{ subtotalCompare | money }}
</s>
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!
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
This is an accepted solution.
For line through, you can use <s> tag in html, for example:
<s>
{{ subtotalCompare | money }}
</s>
I got it! Thank you so much!
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
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025