DEV/TEST

Sorting products

Describes how to sort products by SKU, vendor, name, or quantity.

Yes, you can easily sort the products in the Order Printer Pro templates.

You can sort them by SKU, vendor, name, or quantity. For that, you just need a small piece of code depending on how you want the products to be sorted:

To sort by SKU:

{% assign line_items = line_items | sort: "sku" %}

To sort by name:

{% assign line_items = line_items | sort: "name" %}

To sort by vendor:

{% assign line_items = line_items | sort: "vendor" %}

To sort by Weight:

{% assign line_items = line_items | sort: "weight" %}

To sort by quantity:

{% assign line_items = line_items | sort: "quantity" %}

Note: if you're planning to change the sorting order, e.g. sort weight from higher to lower, you could achieve it by adding reverse to the snippet. As in:

{% assign line_items = line_items | sort: "weight" % | reverse %}

Once you're ready to sort the products in the templates, please do the following:

1- Go to the Manage templates page in Order Printer Pro

2- Click the "Edit template" button next to the template you would like to edit.

3- You will then find the template code in the "Code" tab on the Edit template page

4- Just drop the needed piece of code at the very top of the template code:

5- Once you are done making changes, click the "Save" button.

Done! Now your templates will sort your products according to your preference!

Was this article helpful?

Still puzzling over something?

The agent has read this article — and everything around it. Ask a follow-up and it answers in seconds.