Caymen
1
Hello Shopify community,
I’m looking to add “total savings” onto the cart and checkout page of one of my client’s store.
Essentially, once a visitor is on the cart and checkout page. I want to show the amount they’ve saved from items being on sale.
How can I make this happen? If I need professional help to do so. I’m totally fine with that.
This is a new store and we’re using Debut theme.
Thank you
1 Like
Hi,
You can print total savings on the cart page using below code.
{% assign total_saving = 0 %}
{% for item in cart.items %}
{% if item.variant.compare_at_price > item.variant.price %}
{% assign saving = item.variant.compare_at_price | minus: item.variant.price | times: item.quantity %}
{% assign total_saving = saving | plus: total_saving %}
{% endif %}
{% endfor %}
You Saved: {{ total_saving }}
For showing the saving total on the checkout page, you need an Shopify plus account to make any changes or need to depend on some paid apps.
Hello, I have Shopify Plus account (with checkout enabled to edit) and wondering how I can display the Total Savings on Checkout?
I already have it working on Cart, but unsure how to get it to work on checkout.
Please advise.
Thanks!
where do i exactly put this code please?
1 Like
where you want to show the saving amount in the cart find the cart code file
This works perfectly!
How could you apply the -if/else- statement so that it only displays when discount items are present in the cart?
{% assign total_saving = 0 %}
{% for item in cart.items %}
{% if item.variant.compare_at_price and item.variant.compare_at_price > item.variant.price %}
{% assign saving = (item.variant.compare_at_price | minus: item.variant.price) | times: item.quantity %}
{% assign total_saving = total_saving | plus: saving %}
{% endif %}
{% endfor %}
{% if total_saving > 0 %}
You Saved: {{ total_saving | money }}
{% else %}
{% endif %}