4

Cart savings

  • Live

Avatar
Petter Vettese

I think this is a great implementation that I have done custom for my theme. See attached image (in norwegian). Code (goes below subtotal code snippet in cart pages:


{% 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 %}




Totalt spart


{{ total_saving | money }}


{% endif %}
{% endfor %}


A

Activity Newest / Oldest

Avatar

Debutify Accounts

Status changed to: Live

Avatar

Debutify Accounts

Status changed to: In progress

Avatar

Hi Petter Vettese,
You will be glad to know that we have planned to work on this feature. Soon this feature will be available. Thanks


Avatar

Post moved to this board

Avatar

Debutify Accounts

Status changed to: Planned

Avatar

Petter Vettese

Code


D

Dennis Spallek

Works like a charm petter, thank you. But there is an issue with my theme, did you have it too?

Inside the theme editor, if i change the quantity of a product in the cart, the total saving line disappear. I have to refresh the browser, to bring it back.

Can not test it on live version, because my store is on business.


Avatar

Petter Vettese

Yes, it is probably because you havent updated cart ajax template. Right? And, another issue with the code as is, is that it displays savings "0" when no "on sale" items is in the cart. Not very motivating :P However, this can probably be fixed with an if / else mod to the tag I can see if I can fix soon and update


D

Dennis Spallek

This only works, if you have one item on sale. If you have at least 2, it puts out the savings for every item in a single line. Dont know how to fix


Avatar

Petter Vettese

I have fixed it now


Avatar

Petter Vettese

Ok, not possible to paste code :)


Avatar

Petter Vettese

{% 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 %}




Totalt spart


{{ total_saving | money }}


{% endif %}
{% endfor %}


Avatar

Debutify Accounts

Cool feature Peter! I definitely agree with you that it is worth implementing. We'll have to check how this would play out with our cart discount add-on that is already showing a discounted subtotal as well with Shopify's automatic discounts when applicable. :)