• Resolved tomboersma

    (@tomboersma)


    Hi, I’m using the following script for sorting order items by sku:

    add_filter( 'wpo_wcpdf_order_items_data', 'wpo_wcpdf_sort_items_by_sku', 10, 2 );
    function wpo_wcpdf_sort_items_by_sku ( $items, $order ) {
    	usort($items, function ($a, $b) {
    		return strcasecmp($a['sku'], $b['sku']);
    	});
    	return $items;
    }

    It works fine most of the time, but doen’t use “natural sorting”. F.ex when I have product K8 and K10 then K8 comes after K10 because 8 is higher then 1. Would it be possible to achieve natural sorting?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘natural sorting by sku’ is closed to new replies.