How to show total order weight with New Shopify Order Printer?

Hey all,

With the new Shopify Order printer, our previous template has unfortunately not translated over to the new app.

I’ve tried to find info online but as the app is so new there isn’t a lot of resources available.

Here’s the previous code we used which worked fine, however not any more - sadface.

{% assign total_weight = 0 %}
                        {% for line_item in line_items %}
                            {% assign line_weight = line_item.weight | times: line_item.quantity %}
                            {% assign total_weight = total_weight | plus: line_weight %}
                        {% endfor %}
                        - Weight
                              {{ total_weight | weight_with_unit }}
                        

If anyone could assist it would be really appreciated.

Worked this out myself (after 3 hours of attempts)

The code that worked is as follows:

{% assign total_weight = 0 %}
{% for line_item in line_items %}
{% assign line_weight = line_item.grams | times: line_item.quantity %}
{% assign total_weight = total_weight | plus: line_weight %}
{% endfor %}
- Weight
  {{ total_weight | weight_with_unit }}

Bear in mind this produces KG weight, not Grams - we work in KG as we are a wholesaler. You will have to divide the figure by 1000 to reach a gram figure.