Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1412960

    Hi guys,

    I am trying to remove some of the options from the Woocommerce default product sorting options.
    As per this post here: https://www.businessbloomer.com/woocommerce-remove-rename-add-default-sorting-options-shop/

    This code doesnt do anything On my Enfold sites.

    I found this on another forum post which seems to suggest that the default filters hook has a different name.

    function avia_remove_woocommerce_frontend_search_params() { 
    remove_action('woocommerce_before_shop_loop','avia_woocommerce_frontend_search_params', 20);
    } 
    add_action( 'init', 'avia_remove_woocommerce_frontend_search_params');

    Can you provide me with the correct code to remove some of the options.

    Copied from the article – This code doesnt work with Enfold.

    
    /**
    * @snippet       Remove Sorting Option @ WooCommerce Shop
    * @how-to        Get CustomizeWoo.com FREE
    * @author        Rodolfo Melogli
    * @testedwith    WooCommerce 3.8
    * @donate $9     https://businessbloomer.com/bloomer-armada/
    */
      
    add_filter( 'woocommerce_catalog_orderby', 'bbloomer_remove_sorting_option_woocommerce_shop' );
      
    function bbloomer_remove_sorting_option_woocommerce_shop( $options ) {
       unset( $options['rating'] );   
       return $options;
    }
      
    // Note: you can unset other sorting options by adding more "unset" calls... here's the list: 'menu_order', 'popularity', 'rating', 'date', 'price', 'price-desc'
    #1412968

    Hey Thomas,

    We have an own filter.

    Please check enfold\config-woocommerce\config.php around line 1966:

    
    
    		$product_order['default']		= __( 'Default', 'avia_framework' );
    		$product_order['menu_order']	= __( 'Custom', 'avia_framework' );
    		$product_order['title']			= __( 'Name', 'avia_framework' );
    		$product_order['price']			= __( 'Price', 'avia_framework' );
    		$product_order['date']			= __( 'Date', 'avia_framework' );
    		$product_order['popularity']	= __( 'Popularity (sales)', 'avia_framework' );
    		$product_order['rating']		= __( 'Average rating', 'avia_framework' );
    		$product_order['relevance']		= __( 'Relevance', 'avia_framework' );
    		$product_order['rand']			= __( 'Random', 'avia_framework' );
    		$product_order['id']			= __( 'Product ID', 'avia_framework' );
    
    		/**
    		 *
    		 * @since 4.5.6.2
    		 * @param array $product_order
    		 * @return array
    		 */
    		$product_order = apply_filters( 'avf_wc_product_order_dropdown_frontend', $product_order );
    

    And in the filter use unset() to remove the ordering you do not like.

    If this does not work – do you have a staging site where we can check and have a closer look into it.

    Best regards,
    Günter

    #1412971

    Thanks Gunter,

    Works as expected:

    The working filters are below for functions.php

    For other users comment out the lines that you dont want to remove.

    NOTE If you comment out default – It causes a PHP error. So please keep default enabled.

    // remove unused woo filters
    add_filter( 'avf_wc_product_order_dropdown_frontend', 'thinkjarvis_remove_sorting_option_woocommerce_shop' );
    function thinkjarvis_remove_sorting_option_woocommerce_shop( $product_order ) {
    	unset( $product_order['default'] );
    	unset( $product_order['menu_order'] );
    	unset( $product_order['title'] );
    	unset( $product_order['price'] );
    	unset( $product_order['date'] );
    	unset( $product_order['popularity'] );
    	unset( $product_order['rating'] );
    	unset( $product_order['relevance'] );
    	unset( $product_order['rand'] );
    	unset( $product_order['id'] );
    	return $product_order;
    }
    • This reply was modified 1 year, 4 months ago by thinkjarvis.
    • This reply was modified 1 year, 4 months ago by thinkjarvis.
    #1413003

    Hi thinkjarvis,

    Thanks for posting your code :)
    Thanks as well for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Remove items from default WooCommerce Dropdown filter’ is closed to new replies.