Order Printer - Sort Line Items by Barcode

K-Ciao
New Member
1 0 0

Hi all!

I am using Order Printer to print out our packing slips.

We need to add our product's barcode (as numbers) to the list.

I managed to add the barcode by using {{ line_item.variant.barcode }}, but the problem is I cant sort the Line Items by variant.barcode.

Sorting works if I use SKU, Title, or Price... but not with the variant.barcode?

Here is my code:

<tbody>	   
      {% assign sorted_line_items = line_items | sort: 'variant.barcode' %}
      {% for line_item in sorted_line_items %}

      <tr style="font-size: 10px;">
	    <td>{{ line_item.variant.barcode }}</td>
             <td>{{ line_item.quantity }}</td>
             <td><b>{{ line_item.title }}</b></td>
             <td>{{ line_item.sku }}</td>
             <td>{{ line_item.price | money }}</td>
      </tr>      
    {% endfor %}
  </tbody>

 

Your help is much appreciated!

0 Likes
peterloane
Excursionist
28 2 11

It looks like this does not work using variant object attributes. Someone working for Shopify might confirm?

I tried variant.id, variant.sku and variant.barcode, without success.

 

0 Likes