Skip to main content
Solved

Help needed in HTML code original price and discount price

  • November 15, 2022
  • 1 reply
  • 862 views

Forum|alt.badge.img+2

Hi There, 

I have a question because my developer is on holiday. 

I have a custom made metric for our invoices. And would like to change the lay out of the invoice. Because it doesn’t look good. 

At this moment I have the following lay out: 


I would like to change it into a 3 table view. And want to have the original price and selling price in one column. And the original price with a strike through when there is a discount. 

Now I’ve found the following code.

{% if item.compare_at_price %}<s>{% currency_format item.compare_at_price|floatformat:2 %}</s>{% else %} {% endif %} Price: {% currency_format item.line_price|floatformat:2 %}

I’ve tried to change with my event lines. But it doesn’t work out as it should be. Because he’s only showing the price with the discount. And not the original price. Can you see what I’m doing wrong?

Code I’ve created
{% if event.product_price_regular %}<s>{% currency_format event.line_total|floatformat:2 %}</s>{% else %} {% endif %} Price: {% currency_format event.line_total|floatformat:2 %}

 


Thank you.
Regards a html newbee​​​​​​​

Best answer by Brian Turcotte

Hi @ndil and welcome to the Community!

 

From my initial inspection, it appears that you’ve included the discount price where the regular price ought to be in your conditional statement:

 

{% if event.product_price_regular %}<s>{% currency_format event.line_total|floatformat:2 %}</s>{% else %} {% endif %} Price: {% currency_format event.line_total|floatformat:2 %}

 

In order for your code to mirror the sample code you referenced, this ought to be replaced with event.product_price_regular:

 

{% if event.product_price_regular %}<s>{% event.product_price_regular|floatformat:2 %}</s>{% else %} {% endif %} Price: {% currency_format event.line_total|floatformat:2 %}

 

The item in between the <s> modifiers will be the item that appears with the strikethrough style, which in your case should be the item’s regular price.

 

I hope this helps, and if you require more in-depth help while your developer is away, you’re always welcome to reach out to our wonderful network of developer partners!

 

Thanks for using the Community!

 

- Brian

View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • November 16, 2022

Hi @ndil and welcome to the Community!

 

From my initial inspection, it appears that you’ve included the discount price where the regular price ought to be in your conditional statement:

 

{% if event.product_price_regular %}<s>{% currency_format event.line_total|floatformat:2 %}</s>{% else %} {% endif %} Price: {% currency_format event.line_total|floatformat:2 %}

 

In order for your code to mirror the sample code you referenced, this ought to be replaced with event.product_price_regular:

 

{% if event.product_price_regular %}<s>{% event.product_price_regular|floatformat:2 %}</s>{% else %} {% endif %} Price: {% currency_format event.line_total|floatformat:2 %}

 

The item in between the <s> modifiers will be the item that appears with the strikethrough style, which in your case should be the item’s regular price.

 

I hope this helps, and if you require more in-depth help while your developer is away, you’re always welcome to reach out to our wonderful network of developer partners!

 

Thanks for using the Community!

 

- Brian