sort woocommerce products

How to Sort WooCommerce Products

Changing the product order allow users to easily find results according to their preferences and is an excellent way to improve product visibility and conversions. In this article, we will show you different methods to reorder and sort WooCommerce products

Why Order Products in WooCommerce?

Depending on your store, you can have hundreds or thousands of products. If that’s the case and you don’t have a good search system, it might be difficult for your customers to find their desired items. This can make it harder for them to find what they’re looking for and affect your revenue.

To fix this problem, you can offer numerous ordering features. By adding sorting options (or tweaking the default ones), you can improve the overall shopping experience in your store. For example, you can let your customers quickly get results based on the average sales, product popularity, or even product prices.

Having multiple sorting options can help shoppers find the desired product faster and more efficiently. As a result, sorting products can be very beneficial to your eCommerce store.

Now that we better understand why having options to reorder products can benefit your store, let’s see how to do that properly.

How to Sort WooCommerce Products

There are three main methods to order WooCommerce products:

  1. Using the WordPress Customizer
    1. Using the Block Editor (Gutenberg)
  2. With a WordPress plugin
  3. Through custom snippet (programmatically)

We will take a look at all three methods below, so that you can find your preferred way to complete the task. 

Before we start, make sure you have properly set up WooCommerce on your website without missing any steps to ensure that all these methods will work smoothly.

1) Sort WooCommerce Products using the WordPress Customizer

Changing the default sorting option is one of the easiest things you can do to order products in WooCommerce. You can find this option on the shop page or any page of your store with a product catalog.

default sorting label sort woocommerce products

You can edit the default options just by using the WordPress customizer included in WooCommerce.

Go to Appearance > Customize to open the theme customizer and select WooCommerce.

woocommerce customizer

Then, select Product Catalog and you will see the default WooCommerce product sorting options for the shop page. 

woocommerce default sorting

When you click on it, a drop-down menu will appear showing you the six default product sorting options.

  • Default
  • Popularity (sales)
  • Average rating
  • Recent
  • Price (ascending)
  • Price (descending)

sorting options sort woocommerce products

Select your preferred default option and finally publish the saved changes.

1.1) Sort WooCommerce Products with the Block Editor (Gutenberg)

If you’re using Gunteberg and want to change the order of your products, you can use the Blocks editor. 

From the Blocks tab, select the Hand-Picked Products block that will allow you to change the order of your WooCommerce products.

sort woocommerce products

Simply drag it and select the products you want to display from the list. Note here that the order in which you add the products will be the order in which they are displayed. Change the order later involves removing the products and start again, so choose the order of the products carefully at this step. 

Once you’re happy with your selection, press Done.

That’s it! This is how you can modify the WooCommerce product order through the WordPress dashboard. The main advantage of this method is that it doesn’t require any plugins, technical knowledge, or custom snippets. However, there are some disadvantages too. The default sorting option is minimal and may be very limited in some cases.

If you want more options, have a look at the following methods.

2) Order WooCommerce Products with a Plugin

Another alternative to order WooCommerce products is to use a dedicated sorting plugin. If that’s your case, check out Rearrange Woocommerce Products or WooCommerce Extra Product Sorting Options. They are both excellent plugins to sort products in your online store. 

For this tutorial, we will be using WooCommerce Extra Product Sorting Options. The first thing you need to do is install and activate the plugin on your site.

install WooCommerce Extra Product Sorting Options

Once you have activated the plugin, go to Appearance > Customize from your WordPress dashboard and select the WooCommerce option. Now, select the Product Catalog section and you will get some additional sorting options.

sort woocommerce products - additional sorting

As you can see, the additional options are:

  • Editing the default sorting label
  • Adding new product sorting
  • Removing existing product sorting

By default, WooCommerce will display the “Default Sorting” label when someone visits your shop archive. With this plugin, you can rename it from the customizer itself if needed. Just enter the New Default Sorting Label that you want for the product catalog in the textbox.

new sorting label sort woocommerce products

You will be able to see the preview on the right side of your screen instantly. The changes will be applied to the front end after you publish the saved changes.

default sorting rebranded

Apart from changing the label, you can also add or remove product sorting options.

To add the product sorting options, just check the sorting options that you would like to provide to your customers.

add new sorting option sort woocommerce products

Once you select the options, they will be displayed in the preview automatically.

new sorting options added

Similarly, you can remove sorting options using the plugin. To remove them, just check the options that you want to remove from your website. 

remove product sorting sort woocommerce products

If you look at the preview, you will be able to see that the additional sorting options are now shown on the dropdown menu for sorting.

default options removed

Again, don’t forget to publish it after you have made all the necessary changes.

That’s it! You can now use a dedicated WordPress plugin for sorting the WooCommerce products.

3) Sort WooCommerce Products Programmatically

If you need the most advanced method, the programmatical approach can be the best fit for you. You can modify the sorting option just by placing a simple PHP snippet in your site-specific plugin or the theme’s functions.php file.

For this, you can use a dedicated plugin like Code Snippets for adding the custom codes to your WooCommerce site or create a child theme. If you need help, you can even use one of the child theme plugins for WordPress to create one. But make sure that you back up your WordPress website before we start since we will be modifying some core files of your website.

However, we will go with Code Snippets in this demonstration. So first, install and activate this plugin on your site.

install code snippets

After activation, you will see the plugin’s settings on the left-hand side of your screen. Just go to Snippets > All Snippets and click Add New to add a new snippet.

add new snippet

Now, copy the following code and paste it inside the snippet field. Also, don’t forget to name the snippet so that you can identify them for future updates.

add_filter('woocommerce_default_catalog_orderby', 'quadlayers_default_catalog_orderby');

function quadlayers_default_catalog_orderby( $sort_by ) {
return 'date';
}

woocommerce sorting script sort woocommerce products

If you look at the code, we have added date as the primary sorting option, but you can modify it according to your needs. The available options are:

  • menu_order – the default one
  • popularity – according to the sales
  • rating – by customer rating
  • date – according to the published date
  • price – price low to high sorting
  • price-desc – price high to low
  • rand – random products every time

For example, if you want to sort the products according to customer ratings, you should modify the code like this:

add_filter('woocommerce_default_catalog_orderby', 'quadlayers_default_catalog_orderby');

function quadlayers_default_catalog_orderby( $sort_by ) {
return 'rating';
}

Once you have modified the code, publish the snippet and check your shop page. You will see the new sorting option by default. In this case, it’s sorted with average rating.

sort by rating

Order Products from the Products List

We’ve already established that you can sort WooCommerce products by default from the WordPress Customizer. However, you can also reorder individual products manually using the WooCommerce plugin itself. The products can even be sorted in a random order as default sorting for the customers.

And the best part is that you do not even need to use additional plugins or custom codes for the task. Everything can be reordered just from the dashboard.

So, the first thing you need to do is go to Products > All Products from your WordPress dashboard. You will be able to see it on the left-hand side of your screen.

sort woocommerce products - woocommerce products

On the next page, you can see all the published products. If you take a close look at the page, you will also see an option called Sorting.

sort woocommerce products - woocommerce sorting

If you select that option, and you will be redirected to the product sorting wizard.

By default, WooCommerce will sort the products according to the published date. But through this page, you can easily rearrange using drag and drop. 

sort woocommerce products - woocommerce default sorting

You can easily drag products and drop them in the desired position, as shown above. Once you have done that, check the product archive page from the front-end.

products sorted

This way, you can sort WooCommerce products manually in any order without any additional plugins or codes.

Reorder Specific Products 

When you apply some sorting option globally on your WooCommerce installation, it will reflect site-wide. However, in some ocassions you may only want to reorder specific products.

Let’s say you may need to display a custom product on top of the archive or shop page. The good news is that you can do that using the product editor in WooCommerce.

First, open the product editing wizard, go to Products > All Products and click on Edit for the product that you want to reorder.

edit product sort woocommerce products

Then, you will be redirected to the product editor page. Scroll down under the product data and go to the Advanced tab.

advanced tab

WooCommerce will choose the menu order according to your product published queue by default. So, when you have published your 10th product inside the shop, the menu order will be 10. After publishing your 25th product, WooCommerce will set its menu order as 25, and so on. But from the Advanced tab you can modify it. And that’s what we are going to do to reorder the products.

To bring the specific product to the top of the archive page, use 0 or a minus (-) value. For example, you can use 0 or -1 to bring the product to the top page. In this demo, we will make the menu order as -1. Finally, Update the product once you have modified the value.

new menu order

After that, check your archive page from the front end.

menu order changed

As you can see, we have quickly brought the specific product to the top of the page. To put a different product first, you’d need to a number smaller than -1 like -2 for example.

You can use the previous method from the product lists for it too, but this is a more direct approach since we can place the product in a specific position through the menu order.

Sort Products of a Specific Category

To keep the products handy and accessible to everyone, you can also use categories to sort WooCommerce products. And with a simple snippet, you can add a custom sorting feature to a category archive. This section will tell you more about it.

Make sure that you have got enough product categories in your WooCommerce store. But on our demo website, all we have is an uncategorized category and six products assigned to it.

product category

As you can see, the slug is uncategorized. We will be using this slug later in the snippet. Next, go to the Code Snippets plugin and create a new snippet. Once you have done that, copy and paste this code from below to your website.

add_filter('woocommerce_default_catalog_orderby', 'quadlayers_catalog_orderby_for_category');

function quadlayers_catalog_orderby_for_category( $sort_by ) {
if( !is_product_category('uncategorized') ) {
return $sort_by; // modify uncategorized category archive sorting
}
return 'date';
}

category sorting

If you look at the code, you can see that we have selected the “uncategorized” slug inside the code and used the date filter for sorting. Before publishing the code on your website, replace it with your category slug and sort option.

Once you have done that, publish the snippet.

When you visit the specific category archive, you will see the new sort option by default. In our case, the products are automatically sorted by the latest date.

sort by latest filtering

That’s it! This is how you can sort products of a specific category.

Sort WooCommerce Products Alphabetically

If you have a lot of products, sorting them alphabetically can be a good choice to make your customers’ lives easier. In this section, we will show you how to sort WooCommerce products alphabetically with a simple snippet.

The code you need to use is:

function quadlayers_alphabetical_shop_ordering( $sort_args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'alphabetical' == $orderby_value ) {
$sort_args['orderby'] = 'title';
$sort_args['order'] = 'asc';
$sort_args['meta_key'] = '';
}
return $sort_args;
}
add_filter( 'woocommerce_get_catalog_ordering_args', 'quadlayers_alphabetical_shop_ordering' );

Just add this to the Code Snippet plugin or the functions.php file on your website.

alphabetical sorting

After pasting, publish it. Then, create a label so that the visitors can use the sorting option. To do that, you need the following code:

function quadlayers_custom_wc_catalog_orderby( $sortby ) {
$sortby['alphabetical'] = 'Sort by Name: Alphabetical';
return $sortby;
}
add_filter( 'woocommerce_default_catalog_orderby_options', 'quadlayers_custom_wc_catalog_orderby' );
add_filter( 'woocommerce_catalog_orderby', 'quadlayers_custom_wc_catalog_orderby' );

Create a new snippet once more in the plugin and paste this code there.

alphabetical order sorting

After adding the new snippet, publish it. Now, go to your shop archive and check the dropdown menu for sorting.

sort by alphabetical order

You will see that the WooCommerce products are sorted in alphabetical order.

If you need a no-code solution, you can also use this plugin.

Conclusion

While handling a WooCommerce installation, you have to try multiple ways to boost your conversion rates. Sorting your products can be a good way to provide a better customer experience. As you can see above, all three methods (from the WooCommerce menu, plugin and coding) are simple and don’t need any technical knowledge. 

In addition, we have also added a few more ways to reorder the products from the products list or order specific products. Similarly, we have also included some more product sorting options for you with specific categories and alphabetical order.

We hope that you can sort the products in your store without any issues now. If you found this tutorial helpful, here are some more articles that might be interesting for you:

How are you going to modify the product sorting option? Let us know in the comments below.