How to print only last iteration of for loop on liquid code

{% for transaction in transactions %}
{{ transaction.gateway | payment_method }}
{% endfor %}

{%- assign transaction = transactions  | last -%}

{{ transaction.gateway | payment_method }}

Thank you

Hi brother. In this image, that first product of cost 1598qar is removed from the order. but it still shows in the invoice template. how to remove that too?

can you please share order dashboard screenshot?

it will require me to check code and json response of order

INVOICE


{{ shop_name }}
{{ shop.address }}
{{ shop.city }} {{ shop.province_code }} {{ shop.zip | upcase }}, {{ shop.country }}
Invoice for
{{ order_name }}
Date
{{ "now" | date: "%m/%d/%y" }}

Item Details

{% for line_item in line_items %} {% endfor %}
Product Image Quantity Item Price
{{ line_item.quantity }} {{ line_item.sku }} - {{ line_item.title }} {{ line_item.line_price | money }}

{% if transactions.size > 1 %}

Transaction Details

{% assign transaction = transactions | last %}
Type Amount Kind Status
{{ transaction.gateway | payment_method }} {{ transaction.amount | money }} {{ transaction.kind }} {{ transaction.status }}
{% endif %}

Payment Details

{% for discount in discounts %} {% endfor %} {% if shipping_address %} {% endif %} {% if total_paid != total_price %}

{% assign transaction = transactions | last %}

{% endif %}
Subtotal price: : {{ subtotal_price | money |last }}
Includes discount "{{ discount.code }}" : {{ discount.savings | money }}
Total tax: : {{ tax_price | money }}
Shipping: : {{ shipping_price | money }}
Total price: : {{ total_price | money }}
Total paid : {{ total_paid | money }}
Payment Method : {% assign transaction = transactions | last %}

{{ transaction.gateway | payment_method }} - {{ transaction.amount | money }}

Payment Status : {{ transaction.status }}

{% if note %}

Note

{{ note }}

{% endif %}

Shipping Details

{% if shipping_address %}
{{ shipping_address.name }}
{% if shipping_address.company %} {{ shipping_address.company }}
{% endif %} {{ shipping_address.street }}
{{ shipping_address.city }} {{ shipping_address.province_code }} {{ shipping_address.zip | upcase }}, {{ shipping_address.country }}
{{ shipping_address.phone }}
{{ customer.phone }}
{% endif %}

If you have any questions, please send an email to {{ shop.email }}
or contact us at +974 6658 3338

Copyright © 2022 Halamama all rights reserved.

[www.halamama.com](http://www.halamama.com)

can I share my code to your email?

yes, sure!
skype will be better for quick chat if you have
otherwise email will be okay