How do you sort line items in Order Printer by a Meta field

16 1 7

We have added Bin Locations to our Invoice/Pick sheet via a variant meta field and would like to sort the line items by the Bin.


Using code from another post, I was able to sort by the Line Item Product title (blue bold). But I have exhausted every permutation I can think of to insert the custom meta field (bold green) into the code. Any suggestions or help?


{% assign lineitems = unfulfilled_line_items | sort: "title" %}
{% for line_item in lineitems %}
{% if line_item.fulfillable_quantity > 0 %}
<td><b>{{ line_item.variant.metafields.bin.value }}</b></td>
<td><center>{{ line_item.quantity }}</center></td>
<td>{{ line_item.sku }}</td>
<td><b>{{ line_item.title }}</b><br>
<br> </td>
{% else %}
{% endif %}
{% endfor %}

Reply 1 (1)
Shopify Partner
10 0 3

Hi Paul,


I have the same issue and have a developer try many things to get this to work. It seems that it is not possible and Shopify support have confirmed this. The solution from Shopify support is to create your own app where the order can be exported and sorted by your app and re-imported into order printer. I did not try this. 

At the moment , we are trying to add alphabet letters to our location Numbers and add it to the tiltle and sort that way. Still experimenting with this. Also Numbers stored as a string will sort completely differently than if they were stored as an Integar as far as I know.

If this last experiment fails, we are going to create a simple Desktop app that will get the orders via the api and sort the way we want and then print to a printer.