How to customize the sorting/orderby Dropdown in WooCommerce?

In the previous post, we have seen how we can remove the default sorting drop-down from WooCommerce. In this tutorial, I will show you how you can remove individual sorting options from the default product sorting Dropdown in WooCommerce.

Read Also : Exclude products from a particular category on the shop page in WooCommerce

The default sorting drop down contains 6 sorting options,
1. Default Sorting.
2. Sort by popularity.
3. Sort by average rating.
4. Sort by newness.
5. Sort by price: low to high.
6. Sort by price: high to low.

However you may want to remove some of these options depending on your requirements. You can easily do this by adding following WordPress code snippet to your functions.php file.

// Modify the default WooCommerce orderby dropdown
function my_woocommerce_catalog_orderby( $orderby ) {
    unset($orderby["menu_order"]);  //Remove default sorting option.
    unset($orderby["popularity"]);  //Remove popularity option.
    unset($orderby["rating"]);      //Remove rating option.
    unset($orderby["date"]);        //Remove newness option.
    unset($orderby["price"]);       //Remove price: low to high option
    unset($orderby["price-desc"]);  //Remove price: high to low option
    return $orderby;
}
add_filter( "woocommerce_catalog_orderby", "my_woocommerce_catalog_orderby", 20 );

 

0 Comments

Leave a Comment.