Order Printer - I simply need a sum of Products Ordered

Highlighted
Tourist
8 0 3

Hi, I am trying to get my Order Printer template to display the TOTAL Quantity of items ordered. Have tried line.item_count to no success. What do I need to add to this section of code?

<table class="table-tabular" style="margin: 0 0 1.5em 0;">
  <thead>
    <tr>
      <th>Quantity</th>
      <th>Item</th>
      {% if show_line_item_taxes %}
      <th>Taxes</th>
      {% endif %}
      <th>Price</th>
    </tr>
  </thead>
  <tbody>
    {% for line_item in line_items %}
      <tr>
        <td>{{ line_item.quantity }} x</td>
        <td><b>{{ line_item.title }}</b></td>
        {% if line_item.tax_lines %}
          <td>
            {% for tax_line in line_item.tax_lines %}
              {{ tax_line.price | money }} {{ tax_line.title }}<br/>
            {% endfor %}
          </td>
        {% endif %}
        <td>{{ line_item.price | money }}</td>
      </tr>
    {% endfor %}
  </tbody>
</table>

Thank you.

Jason

1 Like
Highlighted
Shopify Partner
385 0 57

Hello Jason,

This would not really be a build in feature but its easily archievable.

Put this somewhere on the top of the template:

{% assign totalProductsOrdered = 0 %}
{% for line_item in line_items %}
    {% assign totalProductsOrdered = totalProductsOrdered | plus: line_item.quantity %}
{% endfor %}

And then you can access the count anywhere under the snippet by using:

{{ totalProductsOrdered }}

Kasimir

"Good design is good business"
7 Likes
Highlighted
Tourist
8 0 3

Hello Kasimir. You are so kind. Thank you. It helped immediately. Sincerely, Jason

1 Like
Highlighted
New Member
1 0 0

Hi,

 

I would like to loop through all the orders and get a product list with summarised products in total group by products, could anyone give me some tips? Thanks!

 

 

0 Likes
Highlighted
Tourist
4 0 5

Worked for me too! The Shopify "Gurus" didn't help, but you did! Maybe they should hire you... Thanks a bunch!

0 Likes
Highlighted
New Member
1 0 0

My store accepts tips.  When I print the packing slip with the count of total products, it includes Tip in that count.  Is there a way to remove Tip as a line item and remove it from the total count?

0 Likes