Refers to FiboSearch Pro only

Custom sorting on the search results page

WooCommerce allows the search results to be sorted by the following criteria:

Sometimes other plugins or your own business rules may add other sorting positions like alphabetical, for example. Our Pro plugin version doesn’t recognize custom sorting rules. To handle this, you have to create a custom snippet like this:

add_filter( 'dgwt/wcas/tnt/sort_products', function ( $products, $order ) {
    if ( $order === 'alphabetical' ) {
        usort( $products, function ( $a, $b ) {
            if ( $a->name != $b->name ) {
                return $a->name <=> $b->name;
            }
        });
    }
    return $products;
}, 10, 2 );

Learn how to add this snippet to your WordPress.