How do I show compare at price beside line items that are on sale in order confirmation email

How do I show compare at price beside line items that are on sale in order confirmation email

jmofromto
Shopify Partner
3 0 0

Hi, I'm working on editing our order confirmation emails.  I'd like the compare at price to show beside line items that are on sale (variant compare at price is > variant price).  However, I can't quite figure it out.  This is what I have so far, which I know isn't quite right

 

 

          <td class="order-list__price-cell">
            {% if line.variant.compare_at_price != line.final_line_price %}
             <del class="order-list__line.variant.compare_at_price">{{ line.variant.compare_at_price | money }}</del>
            {% endif %}

 

This displays like this:

confirmation email.png

 

This will show the compare at price for the variant for sale items (this is what I want), but this only works if there is a quantity of 1 of the line item.  If there is a quantity of 2 for the line item, then the compare at price will show regardless of whether its on sale or not. This is because "line.final_line_price" adds together the price for all the units in that line.  I tried using "variant.price" but that gives an error.  

Can anyone help with what I'm hoping to do?

 

I would also love to put either "each" or "x [qty]" after the strikethrough compare at price so that its clear that that number is per unit.  But that's a bonus if I can figure out the first part.

Reply 1 (1)

jmofromto
Shopify Partner
3 0 0

I managed to figure out the first part of my question.  The correct code is 

          <td class="order-list__price-cell">
            {% if line.variant.compare_at_price != line.price %}
             <del class="order-list__line.variant.compare_at_price">{{ line.variant.compare_at_price | money }}</del>

 

Now its just the second part of my question that I'm still struggling with.  How to put either "each" or "x [qty]" after the strikethrough compare at price so that its clear that that number is per unit.  If anyone knows how to tack that on, I'd love your help.  The part I'm stuck on is to have it NOT display on regular priced items.  Right now, when I add the text, it adds it for all items on the order, not just the ones that are displaying the compare at price.