All things Shopify and commerce
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello,
Does anyone know of a way to have the items on the packing slips or invoices sort in an alphabetical order? We can have up to 100+ items in an order and have been unsuccessful in finding a solution through Shopify.
Thank you,
Ryan
Don’t know if op is still looking for help, but I found this question when I was looking for the answer myself and wanted to post the answer for other people looking for it.
I don’t know HTML, and Shopify helpfully suggested I borrow money from them to pay an expert for one line of code. Luckily, I am related to a coder who fiddled with it until we got it working! I think Shopify’s default packing slip code is the same regardless of theme, so hopefully this will work for everyone.
Replace the line
{% for line_item in line_items_in_shipment %}
with these lines
{% assign sorted-list= line_items_in_shipment | sort: "title" %}
{% for line_item in sorted-list in line_items_in_shipment %}
Hope this helps someone else!
This did not work for me. I modified the code and the following did work:
In your packing slip template, find the line:
{% for line_item in line_items_in_shipment %}
and replace it with
{% assign lineitems = line_items_in_shipment | sort: "title" %}
{% for line_item in lineitems %}
This code worked for me, but I have a further question. Now that I have my packing slips sorted by title, is there anyway to further sort by "color" or "Option1 Value?"
Yes it also works for me sorting by title, but like you I want to group the products by product type, with each group being alphabetically sorted within each product type group.
Where do we find the original code to edit?
I do not have packing slip under templates in my theme
It's not in the theme code, you have to go through settings to find it. Go to Settings -> Shipping and Delivery -> Edit Packing Slip Template. Should be line 97 or thereabouts.
Ah yes, right!! Thank you it is working now.
I wonder if theme does affect it then? Double checked the code I posted and that is what is working for me. Good to know I should try your if that ever changes! Thanks for posting!
This worked for me - I was able to change it to sort by SKU by replacing "title" with "sku" in the above code snippet.
When testing this change beware the caching behavior of your browser - I was regenerating a packing slip for the same order multiple times - and it was not sorting correctly - when I moved to a different order it worked like a charm. The browser (I presume) was caching the "old" packing slip even though I was going into the order and instructing it to "print packing slip" each time. Just something to watch out for.
Brilliant, thanks! This just made my day 🙂
This worked and it is awesome! Thank you. The only thing is there is now more space between items...can't see where that would be coming from. Eventually a lot of paper will be consumed. Anyone have any ideas?
The spacing issue is worse than I thought. When the packing slip carries over to a second page, items are lost because they 'print' outside the printable margin.
Anyone have any ideas how to compress the items list?!