Refers only to FiboSearch Pro

Custom sorting on the search results page

WooCommerce allows to sort the search results by the following criteria:

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

<?php

/**
 * Handles order by alphabetical
 * Work only in PHP 7 and higher
 */
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 );

You need to add this code to a new file called asfw-filters.php file. This file has to be created in the root directory of your child theme. Please don’t add it directly to your parent theme as it will be removed when you update the theme.