Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1441941

    HI
    I’d like to remove some “sort by” options from the shop page dropdown menu and add “sort by” categories.
    remove:
    custom
    average rating
    random
    product ID

    add:
    categories

    Thank you

    #1442168

    been searching for a solution to that but nothing yet. any idea if this is possible? thanks

    #1442248

    Hi,
    To remove the items that you listed above Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function my_woocommerce_catalog_orderby( $orderby ) {
    	unset($orderby["menu_order"]);
    	unset($orderby["rating"]);
    	unset($orderby["rand"]);
    	unset($orderby["id"]);
    	
            return $orderby;
    }
    add_filter( "avf_wc_product_order_dropdown_frontend", "my_woocommerce_catalog_orderby", 20 );

    the menu will then look like this:
    Enfold Support 5688
    but to add the category item you will need to use the WooCommerce Product Table plugin this is a paid plugin and I don’t know if it will work correctly with Enfold.
    This is the article that says how to add categories to the options.

    Best regards,
    Mike

    #1442294

    Thank you. removing sorting options with the PHP code worked well.
    Will the WooCommerce Product Table plugin which also allows removal of sorting options conflict with the above removal code?

    #1442311

    Hi,
    Glad that this helped, I don’t think that it would conflict but I don’t know for sure and I can’t test, if you do try the plugin you can always keep this in mind as you test.
    In my research and testing I found a working way to add a option “category” to the sort by filter

    add_filter( 'avf_wc_product_order_dropdown_frontend', 'my_add_custom_sorting_options' );
    function my_add_custom_sorting_options( $options ){
    	$options[ 'cat' ] = 'Category';
    	return $options;
    }

    Enfold Support 5704
    but this doesn’t work because there doesn’t seem to be a built-in query to orderby categories, or at least I couldn’t find one. I assume that the plugin creates a query to do this.
    Otherwise perhaps this will put you on the right track and you or your team can write a query for this, I was not able to.

    Best regards,
    Mike

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.