Solved

# How can I display total order weight in my order printer?

Visitor
2 0 0

Dear Shopify community,

for my order printer I would like to display the total weight of the entire order. I've checked the list of available variables (https://orderprinter.shopifyapps.com/259397/templates/variables), but there is no such variable.

Can you help?

Thanks
Pete

Accepted Solution (1)
Tourist
4 1 0

This is an accepted solution.

Thanks for figuring this out!

As written, it failed to multiply the weight when a customer purchased multiple of the same item, so I changed it slightly:

{% assign total_weight = 0.00 %}
{% assign temp_weight = 0.00 %}
{% for line_item in line_items %}
{% assign temp_weight = line_item.weight | times: line_item.quantity %}
{% assign total_weight = total_weight | plus: temp_weight %}
{% endfor %}

Also, Shopify appears to store the weight in grams (even though it is entered in lbs), so where I needed the weight (to the nearest pound) displayed I used this:

{{ total_weight | divided_by: 453.5924 | round }} lbs

Replies 6 (6)
Visitor
2 0 0

There's no solution for this problem? Hope somebody can help.

Excursionist
17 0 5

I understand this was from a while ago but I've also been trying to figure this out.

After an hour I've managed to get it working - SO IT CAN BE DONE..

I'll try to make it as easy as possible to understand.

1. First we create a total_weight variable and assign it to 0.00 outside of the for loop

2. Next we create a temp_weight variable and also assign it to 0.00

``````    {% assign total_weight = 0.00 %}
{% assign temp_weight = 0.00 %}
{% for line in line_items %}``````

3. We then assign the line_item.weight to the temp_weight inside the for loop (this can be anywhere inside the for loop)

``{% assign temp_weight = line_item.weight %}``

4.  Also inside the for loop just beneath the above code we assign the total_weight to be equal to the itself + the temp_weight

`` {% assign total_weight = total_weight | plus: temp_weight %}``

5. Then we just display total_weight wherever we want it.

``weight: {{ total_weight }}``

Can confirm this works. Just needs to be setup correctly.

Tourist
4 1 0

This is an accepted solution.

Thanks for figuring this out!

As written, it failed to multiply the weight when a customer purchased multiple of the same item, so I changed it slightly:

{% assign total_weight = 0.00 %}
{% assign temp_weight = 0.00 %}
{% for line_item in line_items %}
{% assign temp_weight = line_item.weight | times: line_item.quantity %}
{% assign total_weight = total_weight | plus: temp_weight %}
{% endfor %}

Also, Shopify appears to store the weight in grams (even though it is entered in lbs), so where I needed the weight (to the nearest pound) displayed I used this:

{{ total_weight | divided_by: 453.5924 | round }} lbs

Tourist
4 0 4

Thanks to TenRivers for this as it helped me implement this for the new order printer app.

Just wanted to mention that for some users trying to add the order weight to the new order printer app by Shopify, you may need to use the line_item.variant.weight object.

Code used to calculate the weight of the order:

{% assign total_weight = 0.00 %}
{% assign temp_weight = 0.00 %}
{% for line_item in line_items %}
{% assign temp_weight = line_item.variant.weight %}
{% assign total_weight = total_weight | plus: temp_weight %}
{% endfor %}

Code used to show the value:
<p>weight: {{ total_weight | divided_by: 453.5924 | round: 2 | plus: 0.4 }} lbs</p>

Note: the + 0.4 above is input to make up for the box weight that we have set as default.

Tourist
4 1 0

Thanks!  Our store is only open one month of the year (it's a pre-order sale) so I haven't looked into the implications of the new order printer app yet, but thanks for the tweak to keep it working.

Tourist
10 0 1

Hi,
Added this to the template for the new order printer app and it works.
However, it does not seem to work for different sku's.
Eg, if customer orders 2 different products, the weight of only one of the products is appearing?