• // Add WooCommerce orders as a search source
    add_filter( 'admin_search_sources', function( $sources ) {
        $sources['shop_order'] = 'Orders';
        return $sources;
    } );
    
    // Modify the WP_Query arguments for WooCommerce orders
    add_filter( 'admin_search_shop_order_query', function( $query ) {
        $query['post_type'] = 'shop_order';
        $query['post_status'] = array( 
            'wc-pending', 
            'wc-processing', 
            'wc-on-hold', 
            'wc-completed', 
            'wc-cancelled', 
            'wc-refunded', 
            'wc-failed' 
        );
        return $query;
    } );
    

    I’m testing this code snippet to enable search for woocommerce orders. It’s not working. What am I doing wrong?

  • You must be logged in to reply to this topic.