Solved

Can I display total order weight in Shopify's order printer?

Pete8ura
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)
TenRivers
Tourist
3 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

View solution in original post

Replies 3 (3)

Pete8ura
Visitor
2 0 0

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

TwistyPuzzles
Excursionist
14 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. 

 

TenRivers
Tourist
3 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