Advanced Order Export for WooCommerce

Sort by product names

 

Need products sorted alphabetically in your export? Not by order. Not by SKU. By product name.

Here’s how.

Built-in sorting (the easy way)

Good news. Since version 3.2, Advanced Order Export for WooCommerce includes sorting options.

Go to your export profile. Look for “Sort orders by” dropdown. Choose your field. No code needed.

This works for PDF (outdated) and XLS(outdated) formats.

The code below is outdated. Use the dropdown instead.

Sort products inside PDF exports

This code sorts products by “Item Name” within each PDF order.

How it works: Adds a checkbox to your settings. Check it. Products sort alphabetically by name within each order.

Pro tip: Change $key = $row["Item Name"] to $key = $row["SKU"] to sort by SKU instead.

Sort products inside XLS exports

Same idea. For Excel files.

Important setting: Go to Setup Fields. Set “Fill order columns for” to “ALL rows”. Otherwise sorting breaks.

Where to put these snippets

Add to your theme’s functions.php. Each snippet works independently.

Common mistake

Using outdated PDF/XLS sorting code. The dropdown in section “Sort orders by” is now the standard way.

Only use these code snippets if you need product-level sorting inside orders. Not order-level sorting.

Pro tip

Test on a small date range first. Verify products appear alphabetically. Check that orders still group correctly.

Want descending order (Z to A)? Change -1 : 1 to 1 : -1 in the usort line.

Real talk

The built-in dropdown handles 90% of sorting needs. Use that first.

These code snippets are for edge cases. Like sorting products within orders. Or very old plugin versions.

Update to the latest Advanced Order Export for WooCommerce. The dropdown is much simpler.

Have questions? Please submit a support request. We're always happy to help!

Advanced Order Export
for WooCommerce
PRO

From $30
Buy
✓ 30-day money-back guarantee