Shopify packing slip template

I have customized the packing list template, and the template code is as follows:

 {% for line_item in order.line_items %}
    <div class="table-tr table-item">
      <div class="product">
        {% if line_item.image %}
        <img src="{{ line_item.image | img_url: 'small' }}" />
        {% endif %}
        <div>
          {% if line_item.product.title %}
          <div class="product-name">{{ line_item.product.title }}</div>
          {% else %}
          <div class="product-name">{{ line_item.title }}</div>
          {% endif %} {% if line_item.sku %}
          <p>20MG/{{ line_item.sku }}</p>
          {% endif %}
        </div>
      </div>
      <div class="qty">{{ line_item.quantity }}</div>
      <div class="price">
        {% if line_item.original_price != line_item.final_price %}
        <span>{{ line_item.final_price | money }}</span>
        <br />
        <span style="text-decoration: line-through; color: #999">{{ line_item.original_price | money }}</span>
        {% else %} {{ line_item.original_price | money }} {% endif %}
      </div>
      {% if line_item.product.metafields.custom.federal_excise %}
      <div class="stamp">
        {% assign product = line_item.product %} {% if product.collections.size > 0 %} {{
        product.collections.first.title | split: " " | first }} {% else %} — {% endif %}
      </div>
      {% else %}
      <div class="stamp stamp-empty"></div>
      {% endif %}
      <div class="subtotal">{{ line_item.final_line_price | money }}</div>
    </div>
    {% endfor %}

The result is shown in the figure


1、There is clearly an incorrect calculation of the total price corresponding to the row unit price in the figure
2、The unit price, total price, and data in the backend order do not correspond

why?

Hi @user157 ,

Your {{ line_item.final_price | money }} is showing $57.04 but your Shopify admin shows $57.03.
Also the subtotal {{ line_item.final_line_price | money }} is slightly different.
This happens because:

line_item.final_price rounds to 2 decimals but the actual line price might have more precise tax or discount fractions.

Shopify’s backend does the math in cents, so 2 × 28.515 = 57.03, not 57.04.

Use the unit price from line_item.price, or calculate the real unit price like this:

<div class="price">
  {% assign unit_price = line_item.final_line_price | divided_by: line_item.quantity %}
  {{ unit_price | money }}
  {% if line_item.original_price != line_item.final_price %}
    <br>
    <span style="text-decoration: line-through; color: #999">
      {{ line_item.original_price | money }}
    </span>
  {% endif %}
</div>

update your price cell to:

<div class="price">
  {% assign unit_price = line_item.final_line_price | divided_by: line_item.quantity %}
  {{ unit_price | money }}
  {% if line_item.original_price != line_item.final_price %}
    <br />
    <span style="text-decoration: line-through; color: #999">
      {{ line_item.original_price | money }}
    </span>
  {% endif %}
</div>