skip to Main Content

How can the default sorting of the Woocommerce order list be changed. For now each time I enter the order page, orders are displayed as DESC. I would like it to be ASC by default each time I enter the order page. Can anyone help?

2

Answers


  1. Chosen as BEST ANSWER

    As I found another custom order solution in the forum:

    sort-orders-by-paid-date-in-woocommerce-admin-order-list

    I edited the code mentioned in there to the following, which worked out:

        function action_parse_query( $query ) { 
        global $pagenow;
    
        // Initialize
        $query_vars = &$query->query_vars;
        
        // Only on WooCommerce admin order list
        if ( is_admin() && $query->is_main_query() && $pagenow == 'edit.php' && $query_vars['post_type'] == 'shop_order' ) {
    
            
            // Set
            $query->set( 'orderby', 'date' );
            $query->set( 'order', 'ASC' );
        }
    }
    add_action( 'parse_query', 'action_parse_query', 10, 1 );
    

  2. These code will do the work.

    add_filter( 'woocommerce_order_query_args', function ( $args ) {
        $args['order'] = 'ASC';
        
        return $args;
    } );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search