Solved

Help needed in HTML code original price and discount price

  • 15 November 2022
  • 1 reply
  • 525 views

Badge +1
  • Contributor I
  • 0 replies

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​​​​​​​

icon

Best answer by Brian Turcotte 16 November 2022, 16:26

View original

1 reply

Userlevel 7
Badge +36

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

Reply