Display Compare at price/saving on the Cart and Checkout

giuly
New Member
3 0 0

Hi,

I have applied a compare at price on my product, I'd like to display the previous price and the total saving on the cart page and on the checkout page, as currently it is showing only the discounted price, but without reminding the customer about the saving he/she is having.

 

Would you please help me find the code to do this, and also give me the instructions on specifically where to insert this code, both for the checkout page and for the cart page?

 

 

0 Likes
gina-gregory
Shopify Expert
710 48 170

This can be easily done on the cart page, but can only be done in checkout if you're on Shopify Plus.

For the cart page, find where the current item price is and update to something like this:

{{ item.final_price | money }}
{% if item.variant.compare_at_price > item.variant.price %}
  <s>{{ item.variant.compare_at_price | money }}</s>
{% endif %}
0 Likes
gina-gregory
Shopify Expert
710 48 170

For savings, you can calculate like this:

{% assign savings = item.variant.compare_at_price | minus: item.final_price %}
You're saving {{ savings | money }}!
0 Likes
giuly
New Member
3 0 0

Thank you for your help!

Can you please confirm where the code should be placed on the Edit Code section? (e.g. Snippets)

Thanks,

Giulia

 

0 Likes
giuly
New Member
3 0 0

Hi Gina,

Thank you for your help!

Can you please confirm where the code should be placed on the Edit Code section? (e.g. Snippets)

Thanks,

Giulia

0 Likes
gina-gregory
Shopify Expert
710 48 170

My example wouldn't be an exact copy/paste situation. The code and where to put it on the cart template would depend on how your theme is built.

0 Likes