Support » Plugin: Advanced Order Export For WooCommerce » Export specific set of orders

  • Resolved inequitabledistribution

    (@inequitabledistribution)


    Hi,

    I’m trying to figure how I can export a list of orders based on specific order IDs.

    Scenario:
    I would like to export orders with order ID 1, 3, 5 and 9.

    Would this be possible, for me to list all the order IDs for the exact orders I would like to export?
    I know it’s possible to select them manually in the order list, but this becomes time consuming when I need tens of orders spread out amongst hundreds.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author algol.plus

    (@algolplus)

    hi

    please, put following PHP code to functions.php or use https://wordpress.org/plugins/code-snippets/

    class Woe_Custom_Orders_Range {
        function __construct() {
            //add custom input
            add_action("woe_settings_below_orders_range", function ($settings){
                if( !isset($settings['custom_order_ids']) ) $settings['custom_order_ids'] = "";
                echo '<br><br><b>Orders IDs</b><input type=text size=20 name="settings[custom_order_ids]" value="'. $settings['custom_order_ids'] .'">(comma separated)<br>';
            });
            
            //activate hooks only when export starts
            add_filter('woe_settings_validate_defaults', function ($settings) {
                if( !empty($settings['custom_order_ids']) ) {
                    $values = explode(",", $settings['custom_order_ids']);
                    $values = array_filter(array_map("intval",$values));
                    if($values) {
                        $values_list = join(",",  $values);
                        add_filter("woe_sql_get_order_ids_where", function($where, $settings) use($values_list){
                            $where[] = "orders.ID IN ($values_list)";
                            return $where;
                        }, 10, 2);
                        add_filter("woe_get_order_ids", function($ids) use($values){
                            return $values;
                        }, 10, 2);
                        
                    }    
                }    
                return $settings;
            } );        
        }    
    }
    new Woe_Custom_Orders_Range();
    Thread Starter inequitabledistribution

    (@inequitabledistribution)

    Awesome, that’s just what I needed.

    The IDs in the input field are now separated by a comma, but would it be possible to have them separated by a line break? I’ve replaced the input field with a textfield in the code, but I wasn’t able to change from comma to line break.

    I would like to be able to paste the IDs in the following format:

    1
    3
    5
    9

    Plugin Author algol.plus

    (@algolplus)

    just replace line
    $values = explode(",", $settings['custom_order_ids']);
    with
    $values = explode("\n", $settings['custom_order_ids']);

    Thread Starter inequitabledistribution

    (@inequitabledistribution)

    Perfect! Thank you

    Plugin Author algol.plus

    (@algolplus)

    you’re welcome

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.