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:
<?php /** * Handles order by alphabetical * Works only with 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 fibosearch.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.