Adding extra sorting options on the Shop page

When you're on the WooCommerce shop page or on any of the category pages, there are five ways to sort your products: popularity, average rating, newness, price low to high, and price high to low. That's a pretty good range of ways to sort your products. Of course, it doesn't cover every possibility. You may want to have your products randomly sorted, sorted by products on sale, or sorted alphabetically.

As is typically the case with WordPress, someone has already thought of all of these and bundled them into a free plugin.

How to do it…

This is a pretty quick process. First, we'll have to install the plugin.

  1. In the WordPress admin, click on the Plugins menu and then on Add New.
  2. Run a search for WooCommerce Extra Product Sorting Options.
  3. Install and activate the plugin.

    Now that we've installed the plugin, we have to configure a few settings.

  4. From the WordPress admin, go to WooCommerce | Settings | Products | Display.
  5. The plugin gives you the ability to rename the default sorting option with the New Default Sorting Label field. You could name it as something more intuitive to the user; for example, Our Selection.
  6. Just beneath the New Default Sorting Label field, you'll see the Add Product Sorting Options label and several checkboxes. Check as many as you like.
    How to do it…

Note

You might be tempted to give the user all of the options. This isn't necessarily a good idea. The more options you give to users, the more time they'll have to spend processing each option trying to choose one. It's best to include only the options that are most frequently requested.

How it works…

This plugin uses a bunch of WooCommerce hooks to modify the default ordering. In the next recipe, we'll write some code that interacts with these hooks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset