Order Printer App - Discount amount not being displayed

HEMLINE
Visitor
1 0 2

So I would like the 20% discount to be shown on the order printer invoice I sent to my customers. On my POS sales it crosses out the old amount and displays the discounted price. But on my online sales channel sales it does not. Any ideas on how I can alter the code? 

 

Screenshot 2023-06-06 at 1.09.51 PM.pngScreenshot 2023-06-06 at 1.10.35 PM.png

This is my current code...

 

<p style="float: right; text-align: right; margin: 0;">
{{ "now" | date: "%m/%d/%y" }}<br />
Invoice for {{ order_name }}
</p>

<div style="float: left; margin: 0 0 1.5em 0;" >
<strong style="font-size: 2em;">{{ shop_name }}</strong><br /><br />
{{ shop.address }}<br/>
{{ shop.city }} {{ shop.province_code }} {{ shop.zip | upcase }}<br/>
{{ shop.country }}
</div>

<hr />

<h3 style="margin: 0 0 1em 0;">Item Details</h3>

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
<thead>
<tr>
<th>Quantity</th>
<th>Item</th>
<th>Price</th>
{{ discounts_amount }}
</tr>
</thead>
<tbody>
{% for line_item in line_items %}
<tr>
<td>{{ line_item.quantity }} x</td>
<td><b>{{ line_item.title }}</b></td>
<td>
{% if line_item.original_price != line_item.price %}
<s>{{ line_item.original_price | money }}</s>
{% endif %}
{{ line_item.price | money }}
</td>
</tr>
{% endfor %}
</tbody>
</table>


<h3 style="margin: 0 0 1em 0;">Payment Details</h3>

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
{% if discounts_savings != 0 %}
{% for discount in discounts %}{{ discount.savings | times: -1 | plus: subtotal_price | money }}{% endfor %}
{% else %}
{{ subtotal_price | money }}
{% endif %}
<tr>
<td>Subtotal price:</td>
<td>{{ subtotal_price | money }}</td>
</tr>
<tr>
<td>Total tax:</td>
<td>{{ tax_price | money }}</td>
</tr>
{% if shipping_address %}
<tr>
<td>Shipping:</td>
<td>{{ shipping_price | money }}</td>
</tr>
{% endif %}
<tr>
<td><strong>Total price:</strong></td>
<td><strong>{{ total_price | money }}</strong></td>
</tr>
{% if total_paid != total_price %}
<tr>
<td><strong>Total paid:</strong></td>
<td><strong>{{ total_paid | money }}</strong></td>
</tr>


{% endif %}
</table>

{% if note %}
<h3 style="margin: 0 0 1em 0;">Note</h3>
<p>{{ note }}</p>
{% endif %}

{% if shipping_address %}
<h3 style="margin: 0 0 1em 0;">Shipping Details</h3>

<div style="margin: 0 0 1em 0; padding: 1em; border: 1px solid black;">
<strong>{{ shipping_address.name }}</strong><br/>
{{ shipping_address | format_address }}
</div>
{% endif %}

 

 

Replies 2 (2)

Fujihime
Visitor
2 0 1

I'm having the EXACT same problem. Is there no solution yet? 

Brenyo
Visitor
1 0 0

I have the same issue for about 2 months now, it was working fine before. 

 

These are the variables that doesn't work anymore, there might be a few more: 

 

{{ discount.code }} or {{ discount.title }}

{{ discount.amount }}

{{ discount.savings }}

{{ line_item.original_price | money }}

 

The screenshots attached is about an automatic (discount code) purchase and one with a manual discount from the admin. When it’s a manual discount on the product the same template works, it shows both the original price and the discounted price. With an automatic discount it only shows the original price. 

 

The “Discount” line above the subtotal normally wouldn’t show up as it “detects” that there is no discount code used, even though there was. On my custom invoice I had to make a fixed discount line with the following code to get it working again, because without this line the invoice is incorrect. The subtotal price does not add up. 

 

——

<!--Discount fix start--> 

{% if total_discounts != 0 %}

<tr>

    <td style="padding-bottom: 10px;">Discount</td>

    <td style="text-align: right;">- {{ total_discounts | money }}</td>

  <tr>

  {% endif %}

<!--Discount fix end-> 

 

I suspect that if there is a discount code or automatic discount the variable {{ line_item.price | money }} is not working correctly and it shows the value {{ line_item.original_price | money }} instead. I might be wrong here but something is really off. 

 

Making things even worse since this issue is ongoing the Royal Mail click and drop app is pulling the wrong information from {{ line_item.price | money }}  as well for the customs declaration. 

 

This Royal Mail app has a function to fill out the customs declaration including the purchased item’s price. When there was a discount on the product it always pulled the correct, discounted prices for each individual product. It still does if the discount is done manually from the admin, however when it’s a discount code now it's always getting the full price regardless of the discount is clearly showing in the admin.
I’m sure hat these 2 issues are connected and it's not just the Order Printer app. 

 

Invoices with discount.png