Adding each item's price & weight on Packing Slip

Hello,

I was able to add item price on the packing slip with the code below, but it shows ALL prices under each item (repetitive).

Can you please help on adding prices & weight on the packing slip?

{% for item in order.line_items %}
{% if item.sku == line_item.sku %}

{{ item.final_price | money }}

{% endif %}
{% endfor %}

Hi @Amir212

You can try one of them:

{% for item in order.line_items %}
    {% if item.sku != line_item.sku %}
        <span class="line-item-description-line">
            {{ item.final_price | money }}
            {{ item.weight | weight }}
        </span>
    {% endif %}
{% endfor %}

or

{% for item in order.line_items %}
{% if item.sku != prev_sku %}
<tr>
<td>{{ item.final_price | money }}</td>
<td>{{ item.weight }}</td>
</tr>
{% set prev_sku = item.sku %}
{% endif %}
{% endfor %}

I hope it helps @Amir212 !

Hello,

Thank you for the input, but both didn’t work.

I was able to add item price with this code (just in case anyone else needs to):

{% assign final_price = nil %} {% assign line_name = line_item.title %} {% if line_item.variant_title != blank %} {% assign line_name = line_name | append: " - " | append: line_item.variant_title %} {% endif %} {% for item in order.line_items %} {% assign order_name = item.title %} {% if order_name == line_name %} {% assign final_price = item.final_price %} {% endif %} {% endfor %} {% if final_price %} {{ final_price | money }} {% endif %}

If anyone can help with adding the weight that would be great!

Hey @Amir212 ,

When I follow this Shopify documentation: https://shopify.dev/docs/api/liquid/objects/line_item
I realize that you can retrieve the weight by using the variant’s weight property.

Here’s the code snippet:

{% assign final_price = item.final_price %}
{% assign weight = item.variant.weight %}
{{ weight }}

I hope this helps! If it works for you, please mark it as a solution. I am very happy for that. Have a great day!

Can you please tell me the exact place in the template where we should put this code?

I’d like to know this too, please. I am having a hard time showing the weight. It just says 0.0 oz all the time and also that quantity does not line up. Please help.

screenshot of problem