• I’ve added two additional arguments, ‘values’ and ‘compare’, which I hoped it could order the products price between a set min and max within the catalog. Unfortunately, it didn’t work.

    add_filter( 'woocommerce_get_catalog_ordering_args', function( $sort_args ) {
    	$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
    
    	if ( is_shop() ) {
    		switch( $orderby_value ) {
    
    			case 'price':
    			case 'price-desc':
    				$sort_args['value'] 	= [0, 10000];
    				$sort_args['compare']   = 'BETWEEN';
    				break;
    		}
    	}
    	
    	return $sort_args;
    });

    Some advice will be greatly appreciated. Thanks in advance.

  • The topic ‘Orderby price range doesn’t work’ is closed to new replies.