Reading list Switch to dark mode

    Create Custom Order Status WooCommerce

    Updated 6 July 2018

    Today we will discuss about creating custom Order Status in WooCommerce.

    There are some questions regarding the same in everyone mind.

    why do we need custom order statuses ?

    yes there is an answer for that always.

    lets take an example to understand the need of custom order statuses.

    We have different  product types in WooCommerce like simple, variable, downloadable etc.

    Searching for an experienced
    Woocommerce Company ?
    Find out More

    But if we think beyond WoCommerce or any other framework like a general term we can use is eCommerce.

    So in eCommerce it is possible that there can be various types of products. depending upon the need of the user. what WoCoomerce provides us is the most used one.

    So in that different product type can have different features. Based on that a product can have different order status as well. like most of them uses processing, failed, pending payment, cancelled, refunded, completed etc.

    So like i said above i am just giving an example above there can be other custom order status like awaiting shipment, awaiting specification, working/ processing etc.

    So now it’s very much clear why do we need custom order statuses and that’s why never ever a good eCommerce framework restrict to create custom order statuses.

    So in response to above query below is the code to create custom order status in WooCommerce.

    Below code executes on init hook. it can written inside plugin file.

    add_action( 'init', 'customized_woo_order_status', 25 );  
    

     

    function customized_woo_order_status() {
    		register_post_status( 'wc-awaiting-shipment', array(
    			'label'						=> _x( 'Awaiting Shipment', 'WooCommerce Order Shipment status', 'text_domain' ),
    			'public'					=> true,
    			'exclude_from_search'		=> false,
    			'show_in_admin_all_list'	=> true,
    			'show_in_admin_status_list'	=> true,
    			'label_count'				=> _n_noop( 'Approved (%s)', 'Approved (%s)', 'text_domain' )
    		) );
    
    		register_post_status( 'wc-awaiting-approval', array(
    			'label'						=> _x( 'Awaiting Approval', 'WooCommerce Order Approval status', 'text_domain' ),
    			'public'					=> true,
    			'exclude_from_search'		=> false,
    			'show_in_admin_all_list'	=> true,
    			'show_in_admin_status_list'	=> true,
    			'label_count'				=> _n_noop( 'Approved (%s)', 'Approved (%s)', 'text_domain' )
    		) );
    	}
    
    
    

    In above code as we can check we have created two custom order statuses namely Awaiting Approval and Awaiting Shipment. You can chose yours as well :).

    function wc_custom_order_statuses( $order_statuses ) {
     
        $custom_order_status = array();
        $custom_order_status['wc-awaiting-shipment'] = 'Awaiting Shipment';
        $custom_order_status['wc-awaiting-approval'] = 'Awaiting Approval';
     
        return $custom_order_status;
    }
    add_filter( 'wc_order_statuses', 'wc_custom_order_statuses' );

    Still have any issue feel free to create a ticket and let us know your views to make the code better https://webkul.uvdesk.com/en/customer/create-ticket/

    We will surely assist on that. cheers. Or you can check my other blogs here. and if you always love to work for WooCommerce here are some other resources as well

    Thanks for Your Time! Have a Good Day!

     

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home