Surprisingly you cannot sort WooCommerce category archives by title - but it is super easy to add the feature.
A user in the Advanced WooCommerce Facebook group asked: “My client would like to default sort all of their products by title (in descending order). Their website is setup so that all products are displayed using the category archive pages.”
While working on another site I had examined the sort order thoroughly – right down to the SQL level.
When looking at this issue I was surprised that sorting by title was *not* one of the “Default Product Sorting” options.
Find the code – start with text
Under WooCommerce/Settings/Products/Display is “Default Product Sorting“. This is in includes/admin/settings/class-wc-settings-products.php and it has the ‘woocommerce_default_catalog_orderby_options‘ filter to allow the sort options to be changed. Note the use of a dash in the value (‘price-desc‘) for ‘Sort by price (desc)‘ – this is relevant.
The ID in the code is ‘woocommerce_default_catalog_orderby.’ I guessed that this would be how the setting was referenced. I found it in includes/class-wc-query.php (where I found another filter – woocommerce_default_catalog_orderby with which you could override the stored setting).
This same string is also in includes/wc-template-functions.php where I also see the woocommerce_catalog_orderby filter that appears work just like the woocommerce_default_catalog_orderby_options. Here the filter is for the sorting dropdown on the shop page.
We need to make use of two filters to make the new sorting option available in the admin area (to set the default sorting option) and on the front end (to allow users choose it for sorting).
This is nice and simple and there is no need to install a plugin with a lot of other overhead.