• Resolved kaxad

    (@kaxad)


    Currently, Default status is “Processing” But I need to change it to custom order status “New Order” (slug: new-order). Is there a plugin to do that or is there a code that’s gonna solve this problem.

Viewing 7 replies - 1 through 7 (of 7 total)
  • @kaxad
    No need to use plugin. Simply add below functions in your active theme’s function.php file.

    function ahir_register_new_order_status() {
        register_post_status( 'wc-new-order', array(
            'label'                     => 'New Order',
            'public'                    => true,
            'exclude_from_search'       => false,
            'show_in_admin_all_list'    => true,
            'show_in_admin_status_list' => true,
            'label_count'               => _n_noop( 'New Order (%s)', 'New Order (%s)' )
        ) );
    }
    add_action( 'init', 'ahir_register_new_order_status' );

    // Add to list of WC Order statuses

    function ahir_add_new_order_to_order_statuses( $order_statuses ) {
     
        $new_order_statuses = array();
     
        // add new order status after processing
        foreach ( $order_statuses as $key => $status ) {
     
            $new_order_statuses[ $key ] = $status;
     
            if ( 'wc-processing' === $key ) {
                $new_order_statuses['wc-new-order'] = 'New Order';
            }
        }
     
        return $new_order_statuses;
    }
    add_filter( 'wc_order_statuses', 'ahir_add_new_order_to_order_statuses' );

    Now check edit order page in backend and you will see new Status in dropdown, Please test with test order and see the result!

    • This reply was modified 2 years, 11 months ago by Ahir Hemant.
    Thread Starter kaxad

    (@kaxad)

    Hello Ahir! I appreciate your help, but I already have custom order status created “New Order” but the thing is, when I go to checkout and make new order. the default status applied to order after checkout is “Processing” not “New Order” So I’m asking how do I set “New Order” as a default, so when I create new order from checkout, it will automatically be applied as “New order” instead of “Processing”. Thanks.

    Okay so for that you need to use second function in my above comment.

    make sure your already status have key: $new_order_statuses[‘wc-new-order’]

    Thread Starter kaxad

    (@kaxad)

    Hi, unfortunately the code didn’t work. I tried putting both codes in functions.php, but it didn’t set New Order as default order status. when i checkout it still sets Processing as default status.

    Hi @kaxad
    it should work as i tested in local and have did same code in lot of websites.

    Plugin Support Shohan Hossain Nabil – a11n

    (@sohanhossain)

    Hello @kaxad,

    You can use AutomateWoo to create a workflow that will trigger order status change once an order goes to processing status.

    Thanks!

    Plugin Support abwaita a11n

    (@abwaita)

    Hi @kaxad,

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. Hopefully, the above info as well as the plugin suggestion were helpful!

    If you have further questions, please feel free to open a new topic.

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How do I set default order status for woocommerce’ is closed to new replies.