I changed it, but still not working ??
When searching for Avada code, I get this :
function avada_woocommerce_ordering( $query ) {
// We only want to affect the main query.
if ( ! $query->is_main_query() ) {
return;
}
if ( absint( $query->get( 'page_id' ) ) === wc_get_page_id( 'shop' ) || $query->is_post_type_archive( 'product' ) || $query->is_tax( get_object_taxonomies( 'product' ) ) ) {
if ( Avada()->settings->get( 'woocommerce_avada_ordering' ) ) {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
add_action( 'woocommerce_before_shop_loop', 'avada_woocommerce_catalog_ordering', 30 );
add_action( 'woocommerce_get_catalog_ordering_args', 'avada_woocommerce_get_catalog_ordering_args', 20 );
}
}
}
And also :
public function get_catalog_ordering_args( $orderby = '', $order = '' ) {
// Get ordering from query string unless defined
if ( ! $orderby ) {
$orderby_value = isset( $_GET['orderby'] ) ? wc_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
// Get order + orderby args from string
$orderby_value = explode( '-', $orderby_value );
$orderby = esc_attr( $orderby_value[0] );
$order = ! empty( $orderby_value[1] ) ? $orderby_value[1] : $order;
}
$orderby = strtolower( $orderby );
$order = strtoupper( $order );
$args = array();
// default - menu_order
$args['orderby'] = 'menu_order title';
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
$args['meta_key'] = '';
switch ( $orderby ) {
case 'rand' :
$args['orderby'] = 'rand';
break;
case 'date' :
$args['orderby'] = 'date ID';
$args['order'] = $order == 'ASC' ? 'ASC' : 'DESC';
break;
case 'price' :
$args['orderby'] = "meta_value_num ID";
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
$args['meta_key'] = '_price';
break;
case 'popularity' :
$args['meta_key'] = 'total_sales';
// Sorting handled later though a hook
add_filter( 'posts_clauses', array( $this, 'order_by_popularity_post_clauses' ) );
break;
case 'rating' :
// Sorting handled later though a hook
add_filter( 'posts_clauses', array( $this, 'order_by_rating_post_clauses' ) );
break;
case 'title' :
$args['orderby'] = 'title';
$args['order'] = $order == 'DESC' ? 'DESC' : 'ASC';
break;
}
return apply_filters( 'woocommerce_get_catalog_ordering_args', $args );
}